Loading

scanf("%c", &ch)和scanf(" %c", &ch)和scanf("%s", str)的注意事项

scanf("%c", &ch)和scanf(" %c", &ch):

%c会读取回车和空格,所以一定要使用后者,即在%c前面加一个空格。

%s用于读取char[]时,会忽略空格和回车,所以不会有这些问题。

posted @ 2019-09-02 18:05  拾月凄辰  阅读(1233)  评论(0编辑  收藏  举报