我的问题多多,^○^!
#include <stdio.h> void main() { char ch[20]; scanf("%s",ch); printf("\n%s",ch); }
为什么ch变量里的字符串值不能含有空格?如果我需要含有空格该怎么办啊!是不是就不能用scanf()格式来输出了啊,而是用gets()函数来输出啊.
// you are right, in c you can write your program like that
#include <stdio.h> #include <stdlib.h>
int main() { char ch[20]; char ch2[20]; printf("Enter your first string: "); gets(ch); printf("%s\n",ch); printf("Enter your second string: "); gets(ch2); printf("%s\n", ch2); system("pause");
return 0; } // but in C++, you will have more choice.