For example, I have a file with the following contents:
Hello John Smith
Hello Jack Brown
OK I love you
Note that each sentence has some leading white spaces. I want to use std::fstream
to read them line by line, and want to remove the leading white spaces but keep the spaces between the words in a sentence.
My desired output should be as follows:
Hello John Smith
Hello Jack Brown
OK I love you
I also find this post gives many trivial methods to my question. However, I think none of them is elegant in terms of modern C++. Is there any more elegant means?