printf
int main(){
int a;
char b;
float c;
double d;
a = 520;
b = 'A';
c = 3.14;
d = 3.141592653;
printf("数字%d\n", a);
printf("字母%c\n", b);
printf("单精度浮点数%.2f\n", c);
printf("双精度浮点数%11.9f\n", d);
return 0;
}照抄小甲鱼课上的代码却出现了如下报错
'printf' was not declared in this scope
如何解决?
在文件开头加上一句:
#include <stdio.h> #include<stdio.h>
int main()
{
int a;
char b;
float c;
double d;
a = 520;
b = 'A';
c = 3.14;
d = 3.141592653;
printf("数字%d\n", a);
printf("字母%c\n", b);
printf("单精度浮点数%.2f\n", c);
printf("双精度浮点数%11.9f\n", d);
return 0;
} zltzlt 发表于 2020-8-14 18:51
在文件开头加上一句:
谢谢,已经解决了,但是您能告诉我下为什么要这样写吗?想理解一下 Simon_xlj 发表于 2020-8-14 18:53
谢谢,已经解决了,但是您能告诉我下为什么要这样写吗?想理解一下
因为代码中的printf被包含在stdio.h文件中,
#include<stdio.h>的意思是包含标准输入输出头文件!
std是standard的缩写,意思是标准!
io是input和putput的缩写,意思是输入输出!
.h是头文件的意思,h是head的缩写!
页:
[1]