I need to make a program where it can read from a file and write to it. But the problem is, all i can do is read from it and not write to it. This is the code i have so far:
Code:
# include <iostream> # include <fstream> # include <cstdlib> # include <iomanip> # include <string> # include <vector> using namespace std; int main() { string filePath = "C:\\documents\\test\\"; string fileName = ""; string name = ""; char character=' '; ofstream myfile("C:\\documents\\test\\"); ifstream inputFile; vector<string>names(4," "); cout << "Please enter the name of the input file: "; getline(cin, fileName); fileName = filePath + fileName; inputFile.open(fileName.c_str()); while(inputFile.get(character)) { cout << character; } cin.get(); cin.get(); return 0; }
Comment