i write this code to search an user id (defined in NIM as const char[11]) in a text file
where each user data recorded in the text file have the same length (defined in MAX_LINE as const int).
if the user id defined in NIM is found, then the program will overwrite the
existing user data with the new one, or if the user id isn't found, then the
program will create a new one at the end of the file.
this is the content of the file:
1100002096 Kevin Octavio Sistem Komputer 5
1100002070 Albert Gunawan Sistem Komputer 5
the value of NIM is 1100002070, so the data i want to be changed is Albert Gunawan,
Sistem Komputer, and 5. but when the program was executed, the result is really strange...
the first user id, 1100002096 changed to 111100002096, where is the '11' come from?
what part of my code is wrong?
If you want to read in text mode, then you can use the >>operator or getline command (and more things: fgets etc.). And of course it is rewarding to put all data to new line. What I mean:
1100002096 (ENTER)
Kevin Octavio
Sistem Komputer
5
1100002070
Albert Gunawan
...