Columns and formating
Hi i used to used Borland C++ like 3 years ago and then hadn't used C++ again until now. In borland there was a way to space out text into columns (for a console app) and i want wondering how i could do that in MSVC++? I don't even remember how i used to do it or else i'd try it out first and also it could be different or not possible with MSVC++ but i don't see why there wouldn't be a function or something to do it.
Please if someone could give me a very simple piece of source code of like two words being printed into 2 columns or soemthing like that i'd appreciate it.
Thank you
-Lordoftools
It could be you were just using tab characters ('\t'). Ex:
#include <iostream>int main(){ std::cout << "col 1\tcol 2" << std::endl; std::cout << "word 1\tword 2" << std::endl; return 0;}
No im sry it was not '\t', i've been using that right now and it's not working out well because values in the first column change and always messes the spacing up somehow....right now i've been writeing my own functions which add a buffer of spaces to the end of the first column values so that they will all have teh same string length and be lined up ok, but im having some variable convertion problems and would like to know if there was an easy way.
in borland it was something like this but i know im missing some code and maybe have some wrong code:
cout.setf(ios::fixed);
cout.width(20); cout<<"Blah";
cout<<"column 2";
-Lordoftools
in borland it was something like this but i know im missing some code and maybe have some wrong code:
cout.setf(ios::fixed);
cout.width(20); cout<<"Blah";
cout<<"column 2";
-Lordoftools
Then you probably want the std::setw() manipulator in the <iomanip> header, and possible also std::setfill() or std::setprecision().
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement