B
bhalicki
Hi all,
In the following code I am trying to change the contents of a string:
int main()
{
char *string="testing";
rename(string);
return 0;
}
void rename(char *s)
{
printf("Character 1: %c\n",*s);
*s='a';
printf("Character 1 now: %c\n",*c);
}
Anyway, I am sure this is possible but for some reason I'm getting
segmentation faults at line *s='a'; when I attempt to change the value
in which *s is currently pointing to, being the first character in the
string.
Any ideas?
Thanks in advance,
Ben.
In the following code I am trying to change the contents of a string:
int main()
{
char *string="testing";
rename(string);
return 0;
}
void rename(char *s)
{
printf("Character 1: %c\n",*s);
*s='a';
printf("Character 1 now: %c\n",*c);
}
Anyway, I am sure this is possible but for some reason I'm getting
segmentation faults at line *s='a'; when I attempt to change the value
in which *s is currently pointing to, being the first character in the
string.
Any ideas?
Thanks in advance,
Ben.