Formatting Help

This is a discussion on Formatting Help within the C++ Programming forums, part of the General Programming Boards category; I'm doing a program for my class where I input a .txt file and output as another. I have the ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    2

    Exclamation Formatting Help

    I'm doing a program for my class where I input a .txt file and output as another. I have the entire program done. I just don't know how to format it. Its kinda sad. Considering formatting isn't even that difficult from what I understand. Guess I should have paid attention those 2 days. Well I was wonderin if you guys could give me an idea of what I need to do.

    My PrintData.cpp file reads...

    Code:
    #include "WrestlingHeader.h"
    
    void printwrestlerdata(struct person wrestler[], int count, int l, int m, int h)
    {
    	int i;
    	ofstream outdata;
    	outdata.open("Output.txt");
    	outdata<<"Name         Weight         Class"<<endl;
    	
    	
    	for( i = 0; i<count; i++)
    	{
    			outdata<<endl<<wrestler[i].full_name.first<<" "
    			<<wrestler[i].full_name.last<<"         "
    			<<wrestler[i].weight<<"         ";
    		if(wrestler[i].status == lightweight)
    		{
    			outdata<< "Lightweight";
    		}
    		else if(wrestler[i].status == middleweight)
    		{
    			outdata<<"Middleweight";
    		}
    		else 
    	{
    		outdata<<"Heavyweight";
    	}
    	}
    	 outdata<<endl<<endl<<"Total number of Lightweights is "<<l<<endl
    			<<"Total number of Middleweights is "<<m<<endl
    			<<"Total number of Heavyweights is "<<h<<endl
    			<<"Total number in all weight classes is "<<i<<endl;
    	return;
    }
    And its outputing this...

    Code:
    Name         Weight         Class
    
    Mark Bartel         238         Heavyweight
    Bob Byrnes         166         Middleweight
    Tim Holden         95         Lightweight
    Jim Jackson         175         Middleweight
    Dave Johnson         98         Lightweight
    Joe Jones         256         Heavyweight
    Rick Leeds         148         Middleweight
    Ralph Long         158         Middleweight
    Mike Murphy         184         Middleweight
    Dick Nickels         210         Heavyweight
    
    Total number of Lightweights is 2
    Total number of Middleweights is 5
    Total number of Heavyweights is 3
    Total number in all weight classes is 10

    I was wondering, how do I line up the 3 columns?

    Much thanks in advance,
    Zach
    Last edited by ZWarren69; 12-12-2005 at 12:35 AM.

  2. #2
    Banned
    Join Date
    Nov 2005
    Posts
    8
    hmm wouldn't "/t" help?

    ...
    <<wrestler[i].full_name.last<<"\t"
    <<wrestler[i].weight<<"\t";
    ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting two dimensional arrarys
    By omishompi in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2006, 01:05 PM
  2. Simple cout formatting question.
    By guitarist809 in forum C++ Programming
    Replies: 5
    Last Post: 03-27-2006, 12:59 PM
  3. dos game help
    By kwm32 in forum Game Programming
    Replies: 7
    Last Post: 03-28-2004, 06:28 PM
  4. Need a hand formatting numbers.
    By Furious_George in forum C++ Programming
    Replies: 10
    Last Post: 10-15-2003, 11:12 AM
  5. Formatting Standards
    By subdene in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 11-22-2002, 04:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21