小编Har*_*rsh的帖子

试图在C中打印字符数组

我试图在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

0
推荐指数
1
解决办法
2971
查看次数

标签 统计

c ×1