Answers for "print a string using recursion in c"

C
1

print a string using recursion in c

#include <stdio.h>

/**
* rec - a function that prints a string
* Desc: use recursion to print a string one letter at a time
*/
void rec(char *s)
{
        if (*s == '\0')
                return;
        printf("%c", *s);
        rec(s + 1);
}

/**
* main - start of this program
* Desc: implements on rec()
* Return 0 on success
*/
int main()
{
        char str[100] = "My test string";
        rec(str);
        return 0;
}
Posted by: Guest on August-01-2021

Code answers related to "print a string using recursion in c"

Code answers related to "C"

Browse Popular Code Answers by Language