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

0 votes
asked Apr 18 by Lumbini Bimsara (140 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 by Manuel Mateo (1,170 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.