**#include <stdio.h>
#define SIZE 3
void scanA(int array[SIZE][SIZE]); // prototyping
int main()
{
int myarray[SIZE][SIZE];
int i,j;
printf("Please enter the array: \n");
scanArray(myarray);
for(i=0; i<SIZE; i++)
for(j=0; j<SIZE; j++)
{
printf("%c",myarray[i][j]);
}
printf("\n");
return 0;
}
void scanA(int array[SIZE][SIZE]) // function defintion
{
int i;
int j;
for(i=0; i<SIZE; i++) // looping to scan
for(j=0; j<SIZE; j++)
{
scanf("%c\n ",&array[i][j]);
}
}**
// scanA函數中的scanf要求10個字符,雖然它是循環的9倍 我想知道原因和解決方案。爲什麼scanf函數要求額外的輸入?
請不要在此處輸入您的代碼,複製並粘貼從你的編輯器中刪除 – 2015-03-02 21:10:55
刪除'「%c」'後面的空格。http://stackoverflow.com/a/28820181/2410359在正確的軌道上:'「%c」'。 – chux 2015-03-03 01:05:21
「%c」 - 這是行得通的,但是,是什麼原因? – pahan 2015-03-03 03:36:49