Hi
How can I ask the program i'm using (visual c++) to read the file that I have stored
I wrote it this way
#include <iostream>
#include <fstream>
#include <string>
using namespacestd;
int main () {
input_file.open ("C:users\\myname\\document\\myfilename");
output_file<<"hello\n*;
output_file>>name;
}
It did not work
Last edited on
You are missing the declarations:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
ifstream input_file("C:users\\myname\\document\\myfilename");
/*
same as writing :
ifstream input_file;
input_file.open("C:users\\myname\\document\\myfilename");
*/
ofstream output_file("filename");
output_file<<"hello\n";
}
|
Last edited on
You forgot to specify the file you want to open, you need to specify the filename with the extension .txt, .cpp etc.
Not exactly sure what your trying to do but use bazzy example, just remember the file extension.
First thing u should do is give space after namespace and use buzzy example and hey dont forget to return 0; at the end ..... :)