segfault « fgets « C File Q&A

Home
C File Q&A
1.array
2.binary
3.delete
4.Development
5.directory
6.fgets
7.fopen
8.fprintf
9.fscanf
10.fwrite
11.header
12.include
13.input
14.LINE
15.linux
16.open
17.output
18.pointer
19.read
20.size
21.string
22.struct
23.Text
24.windows
25.write
C File Q&A » fgets » segfault 

1. C - fgets segfault    stackoverflow.com

I have the following code:

int get_int(void) {
    char input[10];
    fgets(input, 10, stdin); // Segfault here
    return atoi(input);
}
It gives me a segfault where ...

2. weird segfault in fgets in process    cboard.cprogramming.com

Now the program runs independently on its own. If I just run progb, it reads the config file and completes as expected. That semi-colon caused bitter headache. Thank you for it. But I am back to square one: when I fork a child process from proga to run progb, progb fails at fopen. Any idea why progB fail at fopen?

3. Segfault in fgets    forums.devshed.com

b4 the line that's segfaulting, add something like: printf("string1 points @%p\n", string1); that will tell you the address that string1 thinks the character array starts at. whatever environment you are devloping in, you should run the debugger. you should set a watch on that variable, and everytime it changes you should make sure it points to valid place. then you can ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.