July 1, 2007

Error in C programming in Linux: segmentation fault?

I compile the program with no errors, but when running it give me "segmentation error", help me please.

  1. A segmentation error is caused when the kernel detects an attempt to access memory they program is not allowed to access, and sends a segfault signal, which normally kills the offending process.

    Use a debugger (or print statements) to trace where the program is attempting this illegal access, and work from there.

    Note, in C, these are usually cause by a pointer problem or stack overflow.

  2. If you intend learning C you will eventually become immune to all the segmentation faults you will get! Segmentation faults are most of the time caused by incorrect pointer referencing such as below:

    { int* a;
    *a= 3;
    }

    If you are new to C and want I would suggest you read this guide http://beej.us/guide/bgc/
    It is very very helpful

Tags: ,

Tell a Friend Today!

del.icio.us Digg Furl Reddit Ask BlinkList blogmarks Blogg-Buzz Google Ma.gnolia Netscape ppnow Rojo Shadows Simpy Socializer Spurl StumbleUpon Tailrank Technorati Windows Live Wists Yahoo! Help

Permalink • Print

Track this entry

RSS BlogPulse

RSS Technorati Cosmos

Related Searches

, , , ,