File Prgram execution fault
Title
Question
After execution of this program error comes as "segmentation fault (core dumped)" . how to solve this
C-and-Cpp File-Handling-In-C 06-07 min 10-20 sec
Answers:
This usually happens because you are accessing some memory which is invalid.
Debugged the error with my son's guidance.
Error is not due to invalid memory, since this is not a lengthy code but a simple code.
Error lies in path.
In place of the path in both File.c or readfile.c, we should not type 'ttt' after Home (home/ttt/desktop......), as shown in the code files downloaded. 'ttt' is for the tutor who made the code file.
For us, it should be replaced as shown in our own system's path.
In terminal, we should type pwd and enter. It display our current working directory path. In that we should take what is displayed after home/.
Same should be typed in place of 'ttt' in the code files. Rest all the code is OK.
For eg.: In my terminal, when I typed pwd, it displayed the path home/dell.
So I replaced 'ttt' with dell in both the codes, saved and executed.
It worked at both places (writing file and reading file both).
Login to add comment