我试图在C中打印字符数组,但如果出现任何空格,则不打印数组.这是我的代码:
int main() {
char str[100];
int len = 0;
printf("Enter the string");
scanf("%s", str);
len = strlen(str);
int i = 0;
for (i = 0; i < len; i++) {
printf("%s", str[i]);
}
getch();
}
Run Code Online (Sandbox Code Playgroud)
Input: Bangalore is in India
Output: Bangalore
Run Code Online (Sandbox Code Playgroud)
有什么建议?
c ×1