Basically I have a function, that writes into a .txt file. The user has to input, what will be written in the file. The problem is, every word has a new line, even tho it's written in the same line, while doing the input. But I want it to be the way the user inputs it.
void Log_Write::WriteInLog(std::string LogFileName)
{
system("cls");
std::string input;
std::ofstream out;
out.open(LogFileName, std::fstream::app);
out << "\n\nNEW LOG ENTRY: " << getCurrentTime()<<"\n"; //
while (true)
{
system("cls");
std::cout << "Writing in Log\n\nType 'x' to leave editor!\n\nInsert new entry: ";
std::cin >> input;
if (input == "x")
break;
out << input << "\n"; // How do I change this so it doesn't create a new line for each word
}
out.close();
}
Sample Input:
1st Input:Test Input
2st Input:Next input
Sample Output in file.txt:
Test
Input
Next
Input
(Without the spaces in between!)