Showing posts with label reverse. Show all posts
Showing posts with label reverse. Show all posts

Saturday, May 3, 2008

c code to reverse a string

/*
to reverse a string
*/

#include
#include
#include

void stringReverse(char string[],int length);

main()
{
int length;
char text[80];

printf("please enter the text:");
gets(text);
length=strlen(text);
return EXIT_SUCCESS;
}


void stringReverse(char string[], int length)
{
int ctr=length-1;

while(ctr>=0)
printf("%c", string[ctr]);
printf("\n");
return;
}