求助各位大佬
Int i=1;int num;
Num=1;
Printf(“%d %d %d”,num,num,i);
为什么它的输出值是 1 4203625 2
Num=1是什么意思
谢谢
这个代码无法通过编译呀,你看
奇怪,你那边可以通过编译吗?
$ vim main.c
$ gcc -g -Wall -o main main.c
main.c:1:1: error: unknown type name ‘Int’; did you mean ‘int’?
Int i=1;int num;
^~~
int
main.c:2:1: warning: data definition has no type or storage class
Num=1;
^~~
main.c:2:1: warning: type defaults to ‘int’ in declaration of ‘Num’ [-Wimplicit-int]
main.c:2:1: error: variably modified ‘Num’ at file scope
main.c:2:10: error: invalid initializer
Num=1;
^
main.c:3:8: error: stray ‘\342’ in program
Printf(▒▒▒%d %d %d”,num,num,i);
^
main.c:3:9: error: stray ‘\200’ in program
Printf(▒▒▒%d %d %d”,num,num,i);
^
main.c:3:10: error: stray ‘\234’ in program
Printf(▒▒%d %d %d”,num,num,i);
^
main.c:3:11: error: expected declaration specifiers or ‘...’ before ‘%’ token
Printf(“%d %d %d”,num,num,i);
^
main.c:3:19: error: stray ‘\342’ in program
Printf(“%d %d %d▒▒▒,num,num,i);
^
main.c:3:20: error: stray ‘\200’ in program
Printf(“%d %d %d▒▒▒,num,num,i);
^
main.c:3:21: error: stray ‘\235’ in program
Printf(“%d %d %d▒▒,num,num,i);
^
main.c:3:23: error: expected declaration specifiers or ‘...’ before ‘num’
Printf(“%d %d %d”,num,num,i);
^~~
main.c:3:30: error: expected declaration specifiers or ‘...’ before ‘num’
Printf(“%d %d %d”,num,num,i);
^~~
main.c:3:37: error: expected declaration specifiers or ‘...’ before ‘i’
Printf(“%d %d %d”,num,num,i);
^
$
人造人 发表于 2021-9-20 22:22
这个代码无法通过编译呀,你看
奇怪,你那边可以通过编译吗?
额应该是
int i=1;int num;
num=1;
printf(“%d %d %d”,num,num,i);
c语言的 墨文和 发表于 2021-9-20 22:24
额应该是
int i=1;int num;
num=1;
num 没有初始化,所以输出了一个随机的数字
墨文和 发表于 2021-9-20 22:24
额应该是
int i=1;int num;
num=1;
num=1;
相当于
num=1;
i++; 同学,i++表示先用i的值进行运算,然后i自增;
所以,num其实就是num,也就将num赋值为1;
之后i自增变成2;
而num为负值,因此输出随机数(有时也统一输出0);
还有,变量名要统一,别一会Num一会num. num未赋值,打错了{:10_269:} 咳咳咳咳o! 发表于 2021-9-20 22:28
同学,i++表示先用i的值进行运算,然后i自增;
所以,num其实就是num,也就将num赋值为1;
之后i自 ...
谢谢{:5_95:} 人造人 发表于 2021-9-20 22:27
num 没有初始化,所以输出了一个随机的数字
谢谢了(*^_^*)
页:
[1]