C File i/o help

Started by
14 comments, last by SteveBe 21 years, 7 months ago
Post more information about the error you are getting when opening the file.
I''ve never heard of a SIGSEV!

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
Advertisement
The code compiles and works here; I can save and load files just fine (the search function is faulty, but that wasn''t the issue here). Something else is causing your problem.

When you are stepping through your code, do you step into the loaddirectory() function? It seems strange that fopen() should result in SIGSEGV, but the gets() calls could very easily do that given bad input.
Spock - please tell me in what way is the search function faulty. I want to know my mistakes and learn from them!

And yes, I am stepping into the code. And it comes up with sigsegv fault on the fopen() command.


As for gets() I know there is no error checking (was going to add that when I had the bare bones built) but I'm making sure that my input is valid.


[edited by - SteveBe on August 30, 2002 7:58:13 AM]
I didn''t actually debug the program, I merely experienced that the search function wouldn''t work after loading. It''s probably because you are mixing reads using fgets() and gets() - fgets() will include the newline in the string while gets() will replace the newline with a null character.

fopen() shouldn''t SIGSEGV like that. Does it crash when running a compiled executable outside the development environment and using valid input?
I tested your code in MSVC, no problem in opening the file, but you have another bug in your loadlibrary function. As you read the values in the file using the while loop, you don''t increment the value of your global variable "count". So when you select "find numbers" although you have loaded the file correctly, you have count == 0; and you return false..

hope that helps..
-----------my quote is under construction
mentat - you my sir, are a god!

Thanks for your help. The program now works.

All the best

This topic is closed to new replies.

Advertisement