Quote Originally Posted by jedipenguin View Post
Ok, so I set the value of s just to see what happens. Still getting the segmentation fault.
That is because "s" is a string-literal, and you cannot write to string literals.

Here is a much simpler program:
Code:
int main()
{
   char *s = "abc123";
   s[0] = 'x';
}
This program also crashes, and for the same reason your program crashes. The s is a string-literal, and I'm attempting to change the first character from 'a' to 'x'. Crash.

Only writeable char arrays, and memory allocated from the heap can be modified.
Code:
int main()
{
   char s[] = "abc123";
   s[0] = 'x';
}
This code now doesn't crash, since s is a writeable array of char.

Regards,

Paul McKenzie