String input with space using scanf function in c


 #include<stdio.h>

int main()
{
    char ch[100];
    scanf("%[^\n]", ch);//Input string with space
    printf("%s\n", ch);
    return 0;
}
 

No comments:

Post a Comment