I prepared a program in c language to reverse a string using recursive function
In my program I terminated the string using new line character '\n'
But I want to change my program in the way that if a white space is pressed after typing a word then space bar ' ' should be used to terminate the string and string should be printed in reverse order
but when I used statement
Expand|Select|Wrap|Line Numbers
- if((ch=getchar())!=' ')
- rev();
here is the coding I used to apply my logic
Expand|Select|Wrap|Line Numbers
- void rev(void)
- {
- char ch;
- if((ch=getchar())!='\n')
- {
- rev();
- printf("%c",ch);
- }
- }
Thank you