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.

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.

Edited 6 Years Ago by NicAx64: n/a

Comments
Concise and well written with very useful information provided

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 :)

This article has been dead for over six months. Start a new discussion instead.