Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

What is the code for display an error message If the number exist in the file

0 votes
asked Apr 18, 2020 by Lumbini Bimsara (170 points)

Write a C program enter a number from the key board and store it in the text file called “number.dat”. If the number exist in the file, display an error message. Program should allow to input numbers until user input -99.

1 Answer

0 votes
answered Apr 19, 2020 by Manuel Mateo (1,190 points)
Not sure about the exact code in c, but I'd have a while loop checking through the file to see if any numbers match the input. If it matches a previous number in the file, write something to the console and terminate the program. After a certain amount of attempts, break the while loop.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...