![]() |
|
#1
|
|||
|
|||
C++ PhoneBookI have to write a main program in which I read from a file phonebook.txt into a dynamic array of Phonebook objects and assign data to each.
Using a loop display each object data. Prompt the user to select a number on the array to modify a Phonebook entry. When the user has chosen a valid entry, asks the user if he wants to alter the entire entry or just the phone number. Accepts new data values accordingly. If the user wants to modify the entire entry, create a temporary object to correct location in the array. If the user wants to change the area code and phone number, or change the phone number only, prompt the values, then use the [] or () operator to assign the new values to the proper existing object within the array. After update has taken effect, redisplay the Phonebook entries. If the user exists the program the array info must be save in the file. This is what i have so far... CPP / C++ / C Code:
I'm really stuck there. I have no clue how to read the file into a dynamic array of Phonebook objects and assign data to them. I know firther questions will appear as I go deeper in it. SO I would really appreciate any help. This is for next Monday. Thanks a lot and have a nice/happy weekend! ![]() |
|
#2
|
||||
|
||||
|
Quote:
A few things. What are the errors/warnings your compiler is telling you about? I found a number of things that need to be done before you can even try to read your info in. For example after copying your code and compiling I got the following: Code:
Now, a few of these just need to be addressed. You need to have your code even "see" things like ios, in, cout, endl, FirstName, LastName, AreaCode and PhoneNumber. Computers are dumb, you need to help them. I will help with this little (very very little actually) bit of info. CPP / C++ / C Code:
or, if you prefer: Code:
Now, the next section needs more info from you. CPP / C++ / C Code:
What exactly do you want to do here? Would you like to get user input for each of the variables? Let us know and we may be able to help. BTW, I was able with small amounts of effort get the compiler errors to... Code:
Look your code over, make some changes and post your current state of affairs. One last thing. Quote:
Guess what, don't care, don't care, don't care. I like to help but if you are after solutions without a learning process you came to the wrong place. If you are willing to do the work and learn along the way you are really really at the right place. Your deadlines have nothing to do with the voluntary help you can find here. Clean up your code a bit, and post your next set of questions. Myself or someone will most likely let you know how to take the next step. Mark __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
|
#3
|
|||
|
|||
|
Hello,
Thank you so much.... Quote:
What else does that needs? i really have no clue. This is giving me such a hard time... |
|
#4
|
||||
|
||||
|
Quote:
Well, you made it here, asked questions and used code tags. I think you have at least some clue. To start, were you able to correct some of the things I showed you to get your errors down to the undeclared variables. I see what you are trying to do (well I think I do anyhow) but you need to get to a point that you can begin compiling even if it has runtime problems. So, post your new set of error codes and update your code. Post it here with a direct question/inquiry and we can move further on your problem with the program. Mark EDIT: one last thing. Can you post your phonebook.txt and your implementation file. It may be helpful. __________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
|
#5
|
|||
|
|||
|
Yeah, i think i might be able to do what you told me, i have a class now, so as soon as i get off there, i will come back here and hopefully, you'll help me.
And i can show how's my code and everything. Thanks a lot! Wait for me.... *haha* |
|
#6
|
|||
|
|||
|
Hello there!
I was able to fix some errors but still have 7 errors! What else do you think i need to do; here are the errors showing: Code:
HELP! I'm desperate! |
|
#7
|
||||
|
||||
|
Most of the problem is due to you trying to get at a PhoneBook member with no object. When you have trouble, post changes to your code as well so we know what you are referring to. Here is a stripped down example of your code to get you in the right direction.
CPP / C++ / C Code:
This is just a tossed together example to get you on your way. Once you can compile and run you can try to get the progam to work the way you would like it to. I had to make up my own textfile and just put a single entry on a line (then used getline). I just used strcpy because I am lazy and have to get back to work. Mark Please, ask very specific questions on things you don't understand. It will help someone here actually be helpful. I have reduced your class to just about nothing. Get the print funtion to work then you can worry about the operators later. Fake phonebook.txt Code:
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work." --Thomas Alva Edison "Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety." --Benjamin Franklin "A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes." --Hugh Downs |
|
#8
|
|||
|
|||
|
Hi!
I havent been able to runthe code you gave me because is gives me the following error: phonebookhelp.cpp C:\Documents and Settings\ee181\Desktop\phonebookhelp.cpp(52) : error C2065: 'getline' : undeclared identifier Error executing cl.exe. phonebookhelp.obj - 1 error(s), 0 warning(s) What can i do to fix that? Thanks... |
|
#9
|
|||
|
|||
|
CPP / C++ / C Code:
|
|
#10
|
||||
|
||||
|
Hello,
You could attempt to use a std:: namespace prefix on the getline() calls: CPP / C++ / C Code:
- Stack Overflow __________________
Following the rules will ensure you get a prompt answer to your question. If posting code, please include BB [C] / [C++] tags. Your question may have been asked before, try the search facility. |
Recent GIDBlog
NARMY by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The