
January 6th, 2013, 02:29 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 1
Time spent in forums: 21 m 32 sec
Reputation Power: 0
|
|
String Reversal
Hello,
I have written c code for string reversal.
Program compiles without any error.
But it gives runtime error.
I am not able to catch the code in my error, Please help me.
The code is as follows.
#include <string.h>
#include <stdio.h>
int main()
{
int n_loopcount;
char *source= "Hello";
char *result= " ";
int n_count = 0;
while(*source!= '\0')
{
source++;
n_count++;
}
source--;
for ( n_loopcount = 0; n_loopcount<n_count;n_loopcount++)
{
//printf("%c\n",*source);
*result = *source;
result++;
source--;
}
printf("%s\n",*result);
}
|