Hi! I am very new to C programming. I have difficutly in understanding how the recursion work. One of my home work is to write a function using recursion to enter and display a string in reverse and state whether string contain any space - not to use array or string. I spent whole week but cannot list the space counted. Please help. Below is my code: (display string in reverse OK, but cannot count space:
#include <stdio.h>
void display(char);
int count(int);
int main(void)
{
char string;
printf("Enter a string:\n");
display(string) ;
printf("\n\n");
return 0;
}
void display(char ch)
{
int space;
ch = getchar();
putchar(ch);
if (ch != '\n')
display(ch);
putchar(ch);
#include <stdio.h>
void display(char);
int count(int);
int main(void)
{
char string;
printf("Enter a string:\n");
display(string) ;
printf("\n\n");
return 0;
}
void display(char ch)
{
int space;
ch = getchar();
putchar(ch);
if (ch != '\n')
display(ch);
putchar(ch);
Comment