Home > Back-end >  Detailed point o c a great god answer, it is better to look not to know the answer, thank you for yo
Detailed point o c a great god answer, it is better to look not to know the answer, thank you for yo

Time:10-10

Example 1: int x;
char ch;
The scanf (" % d ", & amp; X);
Ch=getchar ();
Printf (" x=% d, ch=% d \ n ", x, ch);
Execution: 123 (
Output: x=123, ch=10
Case 2 int x;
char ch;
The scanf (" % d ", & amp; X);
The scanf (" % c ", & amp; Ch);
Printf (" x=% d, ch=% d \ n ", x, ch);
Execution: 123 (
Output: x=123, ch=10

Look not to understand the results of this output b
3. The void main ()
{unsigned int a=65535;
Int b=2;
Printf (" a=% d, % o, x %, % u \ n ", a, a, a, a);
Printf (" % b=% d, % o, x, % u \ n ", b, b, b, b);
}
Results:
A=- 1177, 777, 65535 FFFF,
B=776-2177, fffe, 65534

CodePudding user response:

In case 1, 2, X has obtained 123 numerical, ch made a carriage return, therefore, the ch ASCII for 10
Case 3, the integer (int) with the unsigned integer (unsigned int) length is the same, just the meaning of the highest level, the highest int is the judgement of the positive and negative, doesn't mean value, and unsigned int are all positive, and don't need top to determine the positive and negative, so the highest value, when the value of b - 2, the actual storage of 0 xfffe, using the % u (unsigned integer), the output of the minus sign in front of the as the numerical, 0 xfffe are numerical for the original code, which is 65534

CodePudding user response:

Case 1 where I still don't know much about the newline, ch=10, can detailed say
  • Related