console outputs smiley face

后端 未结 3 1794
遇见更好的自我
遇见更好的自我 2021-01-26 07:43

I have this code:

#include \"stdafx.h\"
#include 

typedef struct{
    int s1;
    int s2;
    char c1;
    char* arr;
}inner_struc;


int _tmain         


        
3条回答
  •  时光说笑
    2021-01-26 07:52

    As far, as I can see, you are trying to output the first array element. But instead, you are printing the second one (the arrays are indexed starting from 0, not 1). The second element is 2. Now, please, take a look at this table, as you can see: the number 2 is a smiley face. The problem is that you are outputing a character with code 2, not '2'. In order to output a deuce, make your array look like this:

    char arr[3] = {'1','2','3'};
    

提交回复
热议问题