hello again.
Code:
#include <stdio.h>
int main(void)
{
char ch , array[100]={'\0'};
int i=0 , count , j;
printf("Enter a sentence: ");
while((ch=getchar())!='.' && ch != '?' && ch != '!' )
{
array[i++]=ch;
putchar(ch);
}
putchar(ch); // print single character
printf("\n Reversal of the characters of the words of the sentence: ");
for(count= i-1; count>=0; count--)
{
if( array[count] == ' ' )
{
j=count+1;
while(j>=0 || j<=count)
{
printf("%c" , array[j]);
++j;
}
}
}
putchar(ch);
return 0;
}
I take an error
Code:
./tests
Enter a sentence: hello man.
hello man.
Reversal of the characters of the words of the sentence: man�P�<m��ƍ��@S�#C#2��@�ƍ�S�#e�)>S��y�6J>� @�ƍ�@�ƍ�9@�ƍ��%ƍ��%ƍ�&ƍ�-&ƍ�P&ƍ�[&ƍ�k&ƍ��&ƍ��&ƍ�'ƍ�'ƍ�,ƍ�(,ƍ�Z,ƍ��,ƍ��,ƍ�-ƍ�I-ƍ�_-ƍ��-ƍ��-ƍ��-ƍ��-ƍ�.ƍ�9.ƍ�M.ƍ�^.ƍ�f.ƍ�x.ƍ��.ƍ��.ƍ��.ƍ�R/ƍ�r/ƍ�/ƍ��/ƍ��/ƍ��/ƍ�!�ߍ�����d@@8 ��� @
The output that I want is :
Code:
Enter a sentence: Hello man.
Hello man.
Reversal of the characters of the words of the sentence: man Hello.