Home > Programming > Functions using the "C" programming language > example28.c

 

Previous

Next


/*
    In this example we demonstrate a recursive function that revert the order
    of a string.
*/


#include <conio.h>
#include <stdio.h>

/*
    Function prototype
*/

void push_chars( );

void main()
{
    printf("\n\nWrite something and add '.' at the end.\n");
    push_chars( );
    printf("\n\nAll done...\n");
    getch();
}

void push_chars( )
{
    char c;
    c = getche( );
    if (c=='.')
        printf("\n");
    else
    {
        push_chars( );
        printf("%c",c);
    }
}


© 2004 Jim Valavanis

Previous

Next

1