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.

If the number exist in the file, display an error message.

+3 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.

2 Answers

0 votes
answered Apr 25, 2022 by EntityPlantt (140 points)

Edit:

Sorry, I have misunderstood you then. The answer below is for C++, not C.

Original answer:

Here's the code:

0 votes
answered Apr 29, 2022 by userdotexe (1,340 points)

I'm not sure if you really would want to use a .dat file extension, since it usually uses a certain unreadable (to humans) code: Unreadable Byte Code .DAT file

So instead you might want to use a .txt file extension instead, but you don't have to since a user-created data file can have plain text with no problems.

Anyway, you might want to try to make this in python first, then follow up with C or C++ to get an idea of what to do.

:)

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.
...