Posts by Segfault • 41 points
2 posts
-
1
votes1
answer90
viewsQ: Why do I get this Segmentation Fault?
Why when I declare: char *s = "string"; fscanf(stdin, "%s", s); I get a Segmentation Fault?
-
3
votes1
answer128
viewsQ: Why can’t I modify the string this way?
When we have a declared int variable, and then a pointer to that variable: int x = 10; int *p = &x; To modify the variable x through the pointer, we have to do: *p = 20; But when I declare: char…