Thread: outputting a report arrays of structures

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    3

    outputting a report arrays of structures

    i want to make an output that is going to be 18 down and 3 across. i have a structure made with 3 elements. how do i go about with a for loop to output the 3 columns. like a data table
    thanks

    Code:
    	int x,x2;
    	while(infile)
    	{
    		for(x=0; x<18; x++)
    		{
    			infile>>array[x].code>>array[x].income>>array[x].members;
    		}
    	}
    	cout<<"ID Code		Income		Members"<<endl;
    	cout<<"_________________________________"<<endl;
    
    	for(x=0;x<18;x++)
    	{
    		cout<<array[x].code<<"		";

  2. #2
    *this
    Join Date
    Mar 2005
    Posts
    498
    are you familiar with the header file <iomanip> and function setw()? read up on those and they will help you with your problem.

    you will want to space them apart using setw() when you print each line.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-13-2009, 12:57 PM
  2. Replies: 3
    Last Post: 05-09-2009, 11:06 AM
  3. pointers to arrays of structures
    By terryrmcgowan in forum C Programming
    Replies: 1
    Last Post: 06-25-2003, 09:04 AM
  4. errors with arrays and structures
    By ssjnamek in forum C++ Programming
    Replies: 4
    Last Post: 03-03-2002, 11:48 PM
  5. Newbie Help (Arrays, Structures, Functions,Pointers)
    By tegwin in forum C++ Programming
    Replies: 3
    Last Post: 02-19-2002, 06:29 PM