I am looking for a simple CPP solution to align a string to the right size.
What do I mean by this?
here is an example:
the normal output would be
hello [message]
foo [message]
I would like it to output like this:
hello [message]
foo [message]
note: this is not for aligning a table but rather to know how to align a message by adding certain spaces to the left (or smth).
>Solution :
Like this ?
#include <iostream>
#include <iomanip>
int main()
{
std::cout << std::setw(10) << "Hello" << " [message]" << std::endl ;
std::cout << std::setw(10) << "foo" << " [message]" << std::endl ;
}