C Program to print string using recursion

Simple C program to print string using recursion .
/* C program to print string using recursion */
#include<stdio.h>
void PrintString(char *str)
{
 if(*str=='\0')//null character
 return ;
 printf("%c",*str);
 PrintString(str+1);
}
int main()
{
 char str[20];
 printf("Enter a string: ");
 scanf("%s",str); //to get space gets(str)
 PrintString(str);
 return 0;
}
/* End of the program */



Popular posts from this blog