Then do some work on it. In other words -- I think you missed the point of my post. . . Does you're program check if fopen failed? Either using new or malloc it's up to u. Hard to tell without seeing the source. I didn't have any problems with those other variables.
So the code in the if statement will not execute, period. A few lines from this function, :::::: memcpy abrec. You should identify the platform on which you're working and include information about unusual situations such as 16-bit int types. So, first file should check if there is in source directories or not. It's needed because the symbol names must contain the complete function signature.
If you are going to return an int from CheckFile, it should probably not be 0 on fail. I can't figure out why this is happening. It is more likely that you have caused the problem by using a null pointer for the filename or mode or by trying to open more files than your implementation supports. . But I don't see how that could have crept in if that's all the code.
I was wondering how to solve a Core dumped issue on my C code. A similar problem could arise if this code were compiled on a 64 bit architecture with 64 bit ints. Use anything else, and you're lying to that library, feeding it the wrong kind of function. Then you choose option 2, and fin only is opened. Get answers and train to solve all your tech problems - anytime, anywhere.
Eric -- Eric Korpela An object at rest can never be Click for home page. This is normally the embodiment of the conditions in the first reply to the post. . Better yet, you could return the global errno. . The above is what causes a segmentation violation directly.
Eric -- Eric Korpela An object at rest can never be Click for home page. I would return -1 to indicate an error. So, it's highly recommended that you fix them all. Hi, I have 2 structure. The same process creates the file also. I need to write some data into files.
Hi You have declare poniter fname and intial it also. The debugger should be able to tell you exactly where it detects the problem, and you should be able to view the variables at the time of the crash. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. But, what would happen if you tried to compile that on a 16 bit machine? I need to write some data into files. I am compiling with gcc 4.
Here, try this gcc -g prog. Registration is quick, simple and absolutely free. After that u can use strdup or strncpy. Nothing else executed other than the direct path to that fopen? This is generally more robust than. . This is dangerous, because you might be inadvertently using it later.
Are you sure you downloaded your pset5 distribution code and put it into the folders as described in the pset? Might be u r not creating fname properly. Could you try compiling and running this code to see if you still get a segfault? When I compile it with: g++ -g MatSim. Scanf is special kind of function. Test the file pointer directly, instead of using redirection, to see if it's open. It's more than this solution. The problem appears to be that your compiler is using 16-bit int values.