When I enter
2
Saca (enter)
Program is run directly, I don't understand why the input that there will be a problem, the input of other seems to be output correctly,
Please answer, look at the code is what's the problem??
# include
# include
Int main ()
{
Int I, j, N.
Char a, [N] [100].
The scanf (" % d ", & amp; N);
//getchar ();
for(i=0; i
The scanf (" % s ", a [I]);
//getchar ();
}
for(i=0; i
for(j=0; J
If (j==0)
{
If (a [I] [j] & gt; 'a')
A [I] [j]=[I] a [j] - 32;
}
The else
{
If (a [I] [j] <'a')
A [I] [j]=[I] a [j] + 32;
}
}
Printf (" % s \ n ", a [I]);
}
}
CodePudding user response:
First getchar place to let go of annotation, that means you need to perform getchar (it's role is to empty a newline, otherwise you press enter is equivalent to receive two data, a data correctly, a newline), will you input data, N receive 2, a [0] (the first for loop) to receive a newline, then a [1] receive saca (the second for loop), the for loop is over, so the program can run directly,Second, do not use variables to define the length of the array, namely a [N] [100] into a [100] [100], to be use variables to define the array length, the application of memory, your program can run normally, because of a an array, memory didn't cause conflict, you now, so it is not safe to use,
CodePudding user response:
N't initializeCodePudding user response:
I see, thank you for your bossesCodePudding user response: