Reverse the words of a sentence.
Hello to everyone.
I am trying to solve this exercise :
Enter a sentence: you can jump can't you?
Reversal of sentence: you can't jump can you?
So far , I have this code...
Code:
#include <stdio.h>
int main(void)
{
char ch , array[100]={'\0'};
int i=0 , count ;
printf("Enter a sentence: ");
while((ch=getchar())!='.' && ch != '?' && ch != '!' )
array[i++]=ch;
for(count=0; count<i; count++)
printf("%c" , array[count]);
putchar(ch); // print single character
printf("\n Reversal of the words of the sentence: ");
for(count= i-1; count>=0; count--)
{
if(ch != ' ')
{
}
}
putchar(ch);
return 0;
}
I must to solve it without pointers or strings. :/
I only want an idea..... some similar code without pointers for this.
Only with arrays.
Thank you in advance.