When dealing with files,how can I get a line from the user , and put it in a file ? (I mean that after the user has pressed "ENTER" , put the entire line in a file)
something like : I'm the user and this is a line that I'd like to put in a file
The main goal is to write a program with o(1) memory allocator.
The thing is ,I don't know what's the length of each line.What I need is to get all input into the file without using any primitives.
I've tried :
1 2 3 4 5
std::ofstream tester("tester.txt");
std::cin >> tester.rdbuf(); // program keeps staying in that line
// here is more code
// here also
// ...
but after I type some lines , the code keeps staying in the line "std::cin >> tester.rdbuf();" . Isn't there a way to get a stream of characters straight into a file ? google thinks not .