我知道在 C 编程中,' scanf ' 与 ' & ' 一起用于除字符串之外的所有变量类型(int、float、char、..)。这是我的程序代码。在' scanf '前面,为什么不需要' & '?我可以了解更多关于 scanf 的信息吗?
#include <stdio.h>
#define M 10
int main()
{
int i, n, sum = 0;
int a[M];
do{
printf("Input a positive number less than %d \n",M);
scanf("%d", &n);
}while (!(n >0 && n < M));
printf("Input %d numbers \n",n);
for(i=0; i<n ; i++){
scanf("%d",(a+i));
sum += *(a+i);
}
printf("Sum = %d \n",sum);
}
Run Code Online (Sandbox Code Playgroud)