please give me a code for this problem.....

Objectives: To implement retrieving of data from text file to a record
To implement storing of updated data from the record to a text file
Procedure:

1. Create a structure for a simple telephone directory system named struct telDirectory{}composed ofchar username[20], long telNum, char address[20].
2. Then create a function for each of the choice below, wherein:

(1)Input record values (input records and save it into a text file)
(2)Edit record values (edit records that are saved, and save the updated records in the text file)
(3)Search record values (seach and display the specific record found on the text file and display it on the screen, for simplicity, seach only for the telephone number).
(4)Quit. (Exits the program)
3. For simplicity of your input. Use only 3 elements for your array of structures.

Recommended Answers

All 2 Replies

1. Create a structure for a simple telephone directory system named struct telDirectory{}composed ofchar username[20], long telNum, char address[20].

so starting with your first question,
so about C++ structures fresh your knowledge. http://www.cplusplus.com/doc/tutorial/structures/

and Start to write that structure.

struct tellDirectory
{
 char userName[20];
 long tellNum;
 char address[20];
};

>>(1)Input record values (input records and save it into a text file)
you can do this using the std::cin which is defined in <iostream>
http://www.augustcouncil.com/~tgibson/tutorial/iotips.html
and using cin you can fill your datastructure.

you may define the method like this.

void input_record(tellDirectory& input);

Try I'm there when you get stuck.

commented: Concise and well written with very useful information provided +2

Just some input:

-Using a struct is the best idea. However, watch out if you make a function that
returns with a type of said struct.
-In the struct, you may want to use "string tellNum" (don't forget to include the string header!) instead, as some people (like me) put a space between the area code and the phone number. This would also work for mobiles, where a few people put '+44' instead of '0'.

Hope this helps and good luck :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.