Pages

Thursday, June 28, 2012

reverse string C programming

here is my first attempt to do C programming homework and it end up pretty well..
tas.htm
-->
#include <stdio.h>
#include <string.h>

main()

{

char str[100], rstr[100];

int i,k;

printf("Enter the string to reverse: ");

gets(str);

for (i=strlen(str)-1,k=0; i>=0; i--,k++)

{

rstr[k]=str[i];

}

rstr[k]='\0';

printf("string '%s' reverse '%s'\n",str,rstr);

getch();

}





No comments:

Post a Comment