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.
I'm really lost at the moment so any help would be great.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 );
Also is there a better way for me to get a file name and new file.



LinkBack URL
About LinkBacks


