| | |
File Creation Program
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 2
Reputation:
Solved Threads: 0
Hey guys I made this program that works fine but the thing is I have to add a feature that will ask the user if they have more records to add to the file. Keep adding records until the response is No. Thanks.
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <fstream> using namespace std; int main(){ ofstream outputFile("TestbyCox.txt"); //ofstream will create the file if it doesn't exist, ifstream will not ifstream inputFile; // input file char myString[100]; // length of the string cout << "Enter a string: "; cin.getline( myString, 100, '\n'); cout << "Writting string to file...\n"; outputFile << myString; outputFile.close(); inputFile.open("TestbyCox.txt"); cout << "Reading string from file...\n"; inputFile.getline(myString, 100, '\n'); cout << myString; // Displaying the file contents system("pause"); return 0; }
-7
#2 Oct 26th, 2009
So what's the big problem? You might have to change the structure of the whole problem, such as make a menu such as
Then create a switch statement that processes the requested action.
•
•
•
•
1. Add new string to file
2. Display file contents
3. Quite
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- Get File creation Date (Java)
- Is it Possible to Run a shellscript file using Java Program (Java)
- File Creation Dates: Recoverable? (Windows Vista and Windows 7)
- if a file is still open by another program (C++)
- Help me for 'Sequential File Creation' (C++)
- help file creation (Pascal and Delphi)
- how to open a file after running the program (C++)
- newbie: lock file so only one instance of program runs (C++)
- Verifying the existence of a file with a delphi program. (Pascal and Delphi)
Other Threads in the C++ Forum
- Previous Thread: inherit class from structure
- Next Thread: my dialog box .rc code , something wrong?
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






