Tuesday, 15 May 2012

string - C++ Probllem with output -



string - C++ Probllem with output -

i need user type file want write info too. example: text file want write "hello too"? types to: example, , info come example.txt file , contain hello too. problem cant take string (accname) , and combine .txt create send info text file. hard explain, hope understand :d

int transfersum; string accname; cout << "type business relationship name want send too" << endl; cin >> accname; ofstream mfile; mfile.open ( accname ".txt"); mfile << transfersum; mfile.close();

you should able utilize string concatenation +.

mfile.open ( accname + ".txt");

if not on c++ 11, need c-style string.

mfile.open ( (accname + ".txt").c_str());

c++ string random output

No comments:

Post a Comment