Thread: debugging: sigsegv, segmentation fault???

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Gonzo's Avatar
    Join Date
    Sep 2003
    Posts
    5

    Exclamation debugging: sigsegv, segmentation fault???

    Hi, I'm relatively new to C programming, but have been working on producing a stats program as a way to experiment and put the things I've learnt into practice.

    The program I have compiles perfectly, and the complier does not detect any errors. However, everytime I run the program it crashes.

    I'm debugging with GDB, but haven't done any debugging before and don't really know what I'm seeing when I run the program through the debugger. Depending of whether I use scanf or gets to get the file name, I get one of the following two error messages a) "Program received signal sigsegv, segmentation fault, 0x780224ea in _size_of_stack_reserve__()" or b) "sigsegv, segmentation fault 0xbff7b983 in ?? ()".

    I have no idea what this means, any help in interpreting it would be great. The source code that is failing is below.

    Code:
    void Create_New_Excavation_File ( void )
    void Create_New_Excavation_File ( void )
    {
         
         /* Constants */
         FILE *fp;
         
    
         /* Variables */
         char *filename;
         char *path = "C:\\path_to_folder";
         char *file_extension = ".txt";
         char *full_file_path;
         
         /* Get the file name */
         puts( "Please enter an appropriate name for the new file you wish to create" );
         scanf( "%s", &filename );
         
         printf("%s", filename );
    
         /*full_file_path = ( strcat ( path, filename, file_extension ) );*/
    
         printf("Creating File.....\n");
         
         fp = fopen ( full_file_path , "a" );
         fprintf ( fp, "\n Test text tester- Line two.");
         fclose ( fp );
    I'm really lost at the moment so any help would be great.

    Also is there a better way for me to get a file name and new file.
    Last edited by Gonzo; 09-14-2003 at 04:50 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. debugging segmentation fault
    By -EquinoX- in forum C Programming
    Replies: 4
    Last Post: 10-26-2008, 12:14 PM
  2. SIGSEGV, Segmentation fault
    By micmac700 in forum C Programming
    Replies: 3
    Last Post: 12-13-2006, 03:47 PM
  3. Locating A Segmentation Fault
    By Stack Overflow in forum C Programming
    Replies: 12
    Last Post: 12-14-2004, 01:33 PM
  4. Segmentation fault...
    By alvifarooq in forum C++ Programming
    Replies: 14
    Last Post: 09-26-2004, 12:53 PM
  5. SIGSEGV, segmentation fault
    By StuBarnes4Prez in forum C++ Programming
    Replies: 4
    Last Post: 01-04-2002, 09:26 PM