|
-
June 17th, 2012, 12:19 AM
#1
REVERSE_of_STRING...
I keep getting segfaults when trying to run the code below. It seems Runtime error due to the line the *end = *begin; . Why is that?
#include <stdio.h>
#include <string.h>
void my_strrev(char* begin)
{
char temp;
char* end;
end = begin + strlen(begin)-1;
while(end>begin){
temp = *end;
*end = *begin;
*begin = temp;
end--;
begin++;
}
}
main()
{
char *string = "school";
my_strrev(string);
printf("%s", string);
}
TANUSHREE-AGRAWAL...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|