Hi Everyone,
Just wondering how can I set the field width during printing. For e.g. how do I print something like the following in C++
printf("%-24s,%-24s %u\n", mystr, myint);
Tx !!
Printable View
Hi Everyone,
Just wondering how can I set the field width during printing. For e.g. how do I print something like the following in C++
printf("%-24s,%-24s %u\n", mystr, myint);
Tx !!
Use IO manipulators
http://www.cplusplus.com/reference/i.../manipulators/
Should be like
Code:std::cout << std::left << std::setw(24) << mystr
<< ", 0x"
<< std::hex << std::right << std::setw(8) << std::setfill('0') << myint
<< std::endl;