counting characters

I'm building a program I'm stumped on a part.

I'm wanting to use setw() but for the length of the gap I want it to be the length of the number of characters + 1
so if someones name was 50 characters long it will set that gap at 50 characters long + 1. for in between the "##" and "||"

but there will be a lot of names in the file so the character counter will need to find the name with the most characters in it and count them all.

did I explain my question good enough?

thanks guys.

1
2
3
4
5
6
7
8
9
10
11
12
# include <iostream>
using namespace std;
int main()
{

cout << "## Full Name         || Age ||  Phone || Customer || Member || Started  ||  Last  || Date    || Date Last   ##" << endl      //want it to look like this
		  << "##                   ||     || Number ||  Number  ||        ||  Weight  || Weight || Created || modified    ##" << endl;


system("PAUSE");
return 0;
}
closed account (48T7M4Gy)
lookup std::setfill function
In file ? If I do it in my way, I'll make ad 2D array of string like array[][] where array[][0] is name array[][1] is age etc
After that i can compare the name. Snce array is static you can use std::vector
when I add more information its added to a struct, then saves all the information in the struct to a txt file.
So why not use that struct do take the data ?
closed account (48T7M4Gy)
There wouldn't be much point to formatting the data just for putting it on the file.

If the formatting is for data coming off the file then you would have to size the elements first, ie run through the file twice. To avoid that, you format it as it goes on which means you the field size already.
yes its for displaying the file contents..
I think I'm just going to have a setw(); of 30 or something. sounds too difficult.

wanting it to display the little table first then itl loop through file displaying everything.

thanks
I just realised you can re-size the cmd box.....
Topic archived. No new replies allowed.