output file issue in c++ -


I get the error "no matches" while compiling this code. Can somebody help me out?

  #include & lt; Iostream & gt; # Include & lt; Fstream & gt; # Include & lt; Stdlib.h & gt; #include & lt; String & gt; using namespace std; Int main () {string filename [] = "Hello.txt"; Offream outfile; OutFile.open (filename); If (OutFile.fail ()) // To successfully open the check, {cout & lt; & Lt; "Named file not found \ n"; Exit (1); } Outfile & lt; & Lt; "Hello, this is my output file"; OutFile.close (); System ("pause"); Return 0; }  

EDIT: What about reading and displacement of a file? I'm having problems with the gateline and will not compile it. Can anyone tell this issue?

  #include & lt; Iostream & gt; # Include & lt; Fstream & gt; # Include & lt; Stdlib.h & gt; #include & lt; String & gt; using namespace std; Int main () {char filename [] = "Hello.txt"; String line = "hello, this is my output file"; Offream outfile; OutFile.open (filename); If (OutFile.fail ()) // To successfully open the check, {cout & lt; & Lt; "Named file not found \ n"; Exit (1); } Outfile & lt; & Lt; Line; If (OutFile.is_open ()) OutFile.getline (line); OutFile.close (); System ("pause"); }  

open () a single string No, there is an array of strings.

You are making an array (of one). Try it instead:

  string file name = "halotaxe"; Offream outfile; OutFile.open (filename.c_str ());  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -