How to search and retrieve something from a file? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to search and retrieve something from a file?

I trying to search for ID and display it from a given file that contains data about participants ( name, id,score). My Output( ) function is meant to search for a given id and display it. However, it is not working properly and is only displaying the info of tye last entered participant in the file. Could anyone explain what is wrong here? Thanks!! Here is the source code file:- https://code.sololearn.com/c07S3P7vNX49/?ref=app

4th May 2019, 3:39 PM
Yusha Arif
Yusha Arif - avatar
4 Answers
+ 5
Well sorry, I didn't come with a solution, rather to notify that your code contains invalid characters that will prevent code execution. Try to view the code under ASCII encoding or ISO-8859-1 you'll see these characters. You need to fix that first before anyone here can help you with it. Good luck! 👍 P.S. You forgot to close the main function - no ending curly brackets in main.
4th May 2019, 4:15 PM
Ipang
+ 1
@ipang, I had run this code on CodeBlocks and it wasn't giving any compilation errors, nor did it crash during run time. I might have forgotten to put the braces in the main function while copying the code so that's not that big of a deal. I think my code has a logical error but I can't seem to figure out what it is
5th May 2019, 5:07 AM
Yusha Arif
Yusha Arif - avatar
+ 1
Yusha Arif, Well, if you are sure your code will run with CodeBlocks then I guess there will be someone who uses that IDE who can help you with that problem, just be patient.
5th May 2019, 5:15 AM
Ipang
0
Ipang, i dont think the problem lies in wheather i am using codeblocks, visual studio, devc or anyother IDE. The problem lies in the code itself irrespective of the IDE on which its written. All you need is familiarization with the c++ language. And yes, i am in no hurry and will wait for a reply that can directly answer the question. Btw, thanks for you help!!
5th May 2019, 9:44 AM
Yusha Arif
Yusha Arif - avatar