【发布时间】:2018-03-20 14:10:21
【问题描述】:
我尝试将文本附加到数组,但是当我尝试使用 printf 之后,这似乎不起作用。它确实打印了一个空格。
char text[10][30]; // 10 is text count and 30 text length
printf("Enter text: ");
text[0]=getchar();
【问题讨论】:
-
text[10][30];这不是声明。 minimal reproducible example请 -
对不起,我的意思是字符文本[10][30]
-
getchar()返回一个字符,而不是文本。 -
@freestyle 不完全是。
getchar()返回一个int所以它可以返回EOF(但这里是吹毛求疵) -
你可能想使用fgets