segmentation faults?

This is a discussion on segmentation faults? within the C Programming forums, part of the General Programming Boards category; hi, when i run my program and put input in, it says segmentation fault and ends my program?? does anyone ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    5

    segmentation faults?

    hi,

    when i run my program and put input in, it says segmentation fault and ends my program?? does anyone know why or how to fix this?? Thanks..

  2. #2
    Registered User
    Join Date
    Jul 2004
    Posts
    91
    you'll need to paste some of your code where you think it is seg-faulting..

  3. #3
    .
    Join Date
    Nov 2003
    Posts
    307
    I don't think he understands what a segfault is....

    compile your program like this:
    Code:
     cc myprog.c -g -o myprog
    Run it in debugger like gdb to show you where in your code it bombed.
    Code:
    gdb myprog
    gdb> r
    ................ error messages
    gdb> ba
    Whatever degugger you have go into to help and find the command that does a backtrace or a stack dump. Use that and it will show you where in your code things went South.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    salsa...i'm not for sure what exactly it is, but ussually when i get a segmentation fault it's because i try to dereference a pointer to something that doesn't exist....ussually it's a class....but c doesn't use classes does it?

  5. #5
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,169
    Code:
           SIGSEGV      11       Core    Invalid memory reference
    Essentially, when you run your program the kernel gives you a block of space to use. If you try accessing memory that isn't in that block of space then it will give this error. It's to protect you from bad programs that might try to modify other running programs or data in memory.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble with DMA Segmentation Faults
    By firestorm717 in forum C Programming
    Replies: 2
    Last Post: 05-07-2006, 09:20 PM
  2. oldiofclose.c and segmentation faults
    By sd_padilla in forum C Programming
    Replies: 1
    Last Post: 12-11-2005, 01:24 PM
  3. Segmentation faults on Linked Lists. (Please help!!)
    By summerrainx in forum C++ Programming
    Replies: 3
    Last Post: 03-19-2005, 06:23 AM
  4. segmentation faults pervade
    By ezwise in forum C Programming
    Replies: 8
    Last Post: 02-28-2005, 02:17 PM
  5. Locating A Segmentation Fault
    By Stack Overflow in forum C Programming
    Replies: 12
    Last Post: 12-14-2004, 12:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21