jeudi 21 février 2019

Passing a value while writing inside a file:C++

I need to pass the value of one of the variables(containing the value of a path) to the contents of the file I am writing. Snippet of the code.

 char filepath[100]="/abc/xyz/";

 file.open("outfile,ios::out);

   if(!file)

    {

     cout<<"File creation failed";

    }

    else

    {

     cout<<"New file created"; 

file <<"export\n";

file <<"client=000\n";

file <<"file='filepath/Trial.data'\n";

file <<"select * from   HTTPURLLOC\n";

file.close(); // Step 5: Closing file

}

Ideally it should create a file Trial.data in the location /abc/xyz/ but it doesnt.

Can someone help please.???

Aucun commentaire:

Enregistrer un commentaire