Separate each word from the input in C

#include <stdio.h>
 
 int main()
 {
    char line[80];
    int i;
 
    puts("Enter a line:");
    gets(line);
    puts("Line is : ");
    puts(line);
    for(i=0;line[i]!='';i++)
        if(line[i]!=' ')
            putchar(line[i]);
        else
            printf("n");
    return 0;
 }

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.