我的下面的小程序将从用户获取5个数字,将它们存储到整数数组中并使用函数将它们打印出来.真诚地它不起作用,我的输出总是"00000".我找不到错误,所以我很乐意提出任何建议.谢谢.
#include <stdio.h>
void printarray(int intarray[], int n)
{
int i;
for(i = 0; i < n; i ++)
{
printf("%d", intarray[i]);
}
}
int main ()
{
const int n = 5;
int temp = 0;
int i;
int intarray [n];
char check;
printf("Please type in your numbers!\n");
for(i = 0; i < n; i ++)
{
printf("");
scanf("&d", &temp);
intarray[i] = temp;
getchar();
getchar();
}
printf("Do you want to print them out? (yes/no): ");
scanf("%c", &check);
if (check == 'y')
printarray(intarray, n);
getchar();
getchar();
return 0;
}
Run Code Online (Sandbox Code Playgroud)