c - 如何使用 printf 显示完整编写的程序?

标签 c printf

我的任务是使用 printf 显示一个程序。我的解决方案是用引号遍历每一行。但是当我编译时我卡住了,它要我声明“d”

我在打印整个程序时遇到错误。它要我定义“d” 请帮我解决这个问题。

#include <stdio.h>

int main(void)
{

printf(
"/* This program reads two integers from the keyboard and prints their product."
"Written by: A Katheravan"
"Date : 10/02/2012"
"*/"

"#include <stdio.h>"
"int main (void)"

"{"
"//Local Definitions"

"int number1;"
"int number2;"
"int result;"

"//Statements"

"scanf("%d", &number1);"
"scanf ("%d", &number2);"
"result = number1 * number2;"
"printf("%d", result);"
"return 0;"

"}"
"//main");

return 0;
}

最佳答案

以下内容可能对您有用:

FILE * fp = fopen("program.c", "r");  

char c;
while ((c = fgetc(fp)) != EOF)   
    printf("%c", c);

fclose(fp);

关于c - 如何使用 printf 显示完整编写的程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12720339/

相关文章:

c - "assignment makes integer from pointer without a cast"在 c

c - 发送指向外部函数的指针使其为空后,它不会变为空

c - 尝试格式化我的 printf 以排列美元符号和美分 - c 源代码

c - Linux 中的 printf 无法正常工作

c - 在C中打印指针的地址

正则表达式精确匹配

c - 需要帮助理解 C 函数中的此 ASM 代码

c - 如何在 C 中实现 typeof 运算符

c - Openssl:RSA_verify() 支持什么 RSA 签名方案?

c - printf 的 h 和 hh 修饰符的用途是什么?