#include<stdio.h>
#include<string.h>
int main(){
char sen[100];
int i=0,len;
printf("Enter a senetence\n");
scanf("%s",sen);
len=strlen(sen);
char ch=sen[i];
while(i<len){
if(ch==' '){
printf("\n");
i++;
ch=sen[i];
continue;
} //i dont know what is the flaw with the logic.
printf("%c",ch);
i++;
ch=sen[i];
}
return 0;
}
The aim of the program is to print the words of a sentence separately. However, this program is successful in printing only the first word. Please tell me where I am going wrong.