printf("%s")返回符号

lwm*_*lwm 1 c printf

做K&R练习1-16,并且想要简单地打印char数组的内容.

#define MAXLINE 1000        /* max num of input chars */
char longest[MAXLINE];      /* char array to hold longest input */

...get input, store, calculate longest input line...

printf("Length : %d, Text was : %s\n", max, longest);
Run Code Online (Sandbox Code Playgroud)

我得到这个作为输出:

来自C程序的shell输出

我应该怎么做才能打印文本,那些是unicode字符?

PS.我到处搜索......

Jim*_*ter 8

更改

(c = getchar() != EOF)
Run Code Online (Sandbox Code Playgroud)

(c = getchar()) != EOF
Run Code Online (Sandbox Code Playgroud)

您的版本为每个读取的字符设置c为1,为eof设置为0.