我可以编译我的代码而不会出错,但它无论如何都不起作用


#include<stdio.h>
#include<conio.h>
int main(){
int marks[3];
printf("enter number for first array");
scanf("%d",marks[0]);
printf("enter number for second array");
scanf("%d",marks[1]);
printf("enter number for third array");
scanf("%d",marks[2]);
printf("the value of first array is %d",marks[0]);
printf("the value of first array is %d",marks[1]);
printf("the value of first array is %d",marks[2]);
return 0;   
}

我期望它会打印矩阵的值,但它一直说这个程序意外地关闭了

scanf()期望您传递要填充的变量的地址,例如:

scanf("%d",&marks[0]);

&是地址运算符,它提供:

最新更新