Center text in fixed-width field with stream manipulators in C++
Here’s a helper class that accomplish what you want: It’s used simply by calling centered(“String”), like so:
Here’s a helper class that accomplish what you want: It’s used simply by calling centered(“String”), like so:
You are almost there, the error is most probably1 caused because you are trying to call getline with second parameter stringstream, just make a slight modification and store the data within the std::cin in a string first and then used it to initialize a stringstream, from which you can extract the input: 1. Assuming you have included: