| | |
Address Book C++ - Help!
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2008
Posts: 13
Reputation:
Solved Threads: 0
Okay, so im new to this website/forum. I am in programming 12, and as my final project in C++ I have decided to create an address book application. It will be "simple" and I was hoping to be able to get it to be able to:
1) Create new entry.
2) View all entries.
3) Edit an entry.
4) Delete an entry
I have very minor knowledge in I/O using files, and was hoping to get some help or a tutorial that might help.
Thanks.
1) Create new entry.
2) View all entries.
3) Edit an entry.
4) Delete an entry
I have very minor knowledge in I/O using files, and was hoping to get some help or a tutorial that might help.
Thanks.
Start by doing the in-memory parts and then you can add serialization to file once it working the way you want. This way you can incrementally add features and also be able to prove to us that you're actually working when you ask for help on the file I/O parts. But a simple google search will give you tutorials and reference material on file I/O as well.
I'm here to prove you wrong.
•
•
Join Date: Sep 2008
Posts: 13
Reputation:
Solved Threads: 0
So what you're saying is;
Show us your basic source code and come back when your AT the problem?
What I know so far:
How to "CREATE" a file using i/o in files.
How to "OPEN/Read" a file.
Because what I need to know at the moment is:
How to "CREATE" a file that the user can name. ( I guess I mean an input, example:
" I would like to create a file named 'x' "))
How to "EDIT" a file.
While I probably appear to be another student with a project looking for YOU to make the program for me, I just can't seem to find a tutorial that says how to do these functions.
Thanks
Show us your basic source code and come back when your AT the problem?
What I know so far:
How to "CREATE" a file using i/o in files.
How to "OPEN/Read" a file.
Because what I need to know at the moment is:
How to "CREATE" a file that the user can name. ( I guess I mean an input, example:
" I would like to create a file named 'x' "))
How to "EDIT" a file.
While I probably appear to be another student with a project looking for YOU to make the program for me, I just can't seem to find a tutorial that says how to do these functions.
Thanks
>Because what I need to know at the moment is:
>How to "CREATE" a file that the user can name.
>How to "OPEN/Read" a file.
I'm a strong believer in separate objects for reading and writing. It makes life so much easier when you're not trying to keep up with a read-write stream, so to open a file for reading you would do this:
>How to "EDIT" a file.
Editing a file ultimately ends up as "replacing" the file in practice. Unless you're appending to a file, making changes to random records in a sequential file usually means you have to make all of your changes in memory, then completely overwrite the file (okay for smaller files) or use temporary files to copy and interleave the unchanged segments and your changes, then overwrite the original file with the finished temporary.
>How to "CREATE" a file that the user can name.
C++ Syntax (Toggle Plain Text)
std::string filename; std::cout<<"Enter a filename: "; if ( getline ( std::cin, filename ) ) { // Opening for writing will create the file if it doesn't exist // If the file does exist, it will be truncated // Note: The constructor requires a C-style string std::ofstream out ( filename.c_str() ); // ... }
I'm a strong believer in separate objects for reading and writing. It makes life so much easier when you're not trying to keep up with a read-write stream, so to open a file for reading you would do this:
C++ Syntax (Toggle Plain Text)
// Filename from the previous example std::ifstream in ( filename.c_str() ); // Read from the file like you would std::cin
Editing a file ultimately ends up as "replacing" the file in practice. Unless you're appending to a file, making changes to random records in a sequential file usually means you have to make all of your changes in memory, then completely overwrite the file (okay for smaller files) or use temporary files to copy and interleave the unchanged segments and your changes, then overwrite the original file with the finished temporary.
I'm here to prove you wrong.
•
•
Join Date: Sep 2008
Posts: 13
Reputation:
Solved Threads: 0
> I'm sorry, didn't I just answer that question with my last post?
Im sure you did, I probably just didn't realize it.
So what I have so far is;
Ability to open/read file in c++, ability to create the file in c++.
Sorry for asking the same question over an over, but did you explain to me how to "write" inside of the text file I created? You probably did, im just blind.
Im sure you did, I probably just didn't realize it.
So what I have so far is;
Ability to open/read file in c++, ability to create the file in c++.
Sorry for asking the same question over an over, but did you explain to me how to "write" inside of the text file I created? You probably did, im just blind.
•
•
Join Date: Sep 2008
Posts: 13
Reputation:
Solved Threads: 0
Okay, perhaps I phrased this wrong, what I am wanting to do is find the code that I need to enable the user (like a cin) to write in that text file.
I know how to write in the file like this,
But how would I alter the code so that the user can write in the file?
I know how to write in the file like this,
ofstream myfile ("filename.txt");
if (myfile.is_open())
{
myfile << "This is me writing in the file.\n";
myfile.close();
}But how would I alter the code so that the user can write in the file?
![]() |
Similar Threads
- A C++ Simple Address book (C++)
- Creating a Address Book using Random Access Files (Visual Basic 4 / 5 / 6)
- C++ Address Book (C++)
- Where does Address Book & email hide? (Web Browsers)
- lost address book addresses (OS X)
- Address book deleted? HELP (OS X)
- Saving Address book and Messages in Outlook Express (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: Makefile
- Next Thread: extract numbers from char
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






