// ...
std::string filename;
std::cout << "Save as (give name for file): ";
std::getline(std::cin, filename);
YourFileName.open(filename); // C++11 (may not work if your compiler is old)
// YourFileName.open(filename.c_str()); // C++98 (should work on all compilers)
// ...
I get error on line 8 > YourFileName.open(filename);
: Edit i saw the YourFileName.open(filename.c_str()); working now.. is there anyway to save it to .txt? without type the filename then .txt ?
Thanks working!
got a new question..
i ge tthis error
1 2 3 4 5
mingw32-g++.exe -Wall -fexceptions -g -c C:\Users\MW\Desktop\Test2\Cout.cpp -o obj\Debug\Cout.o
C:\Users\MW\Desktop\Test2\Cout.cpp: In function 'void main_2()':
C:\Users\MW\Desktop\Test2\Cout.cpp:8:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings (0 minutes, 0 seconds)
whit this code
1 2 3 4 5 6 7 8 9
#include <iostream>
void main_2()
{
std::string Coutname, Coutw, Coutexit;
Coutname = "Save as... (Give name for file) :";
Coutw = "Writing To File...\n";
Coutexit = "Press <Enter> To Exit. \n";
return 0;
}