Im brand new to C++ & Im having trouble with this program im writing i got all the way to the end of it working im just having problems using the setw function in reading and outputting from a file. I have my code attatched for what mine looks like, input file, and another screen shot for what it should look like. If you can give me any pointers in where i went wrong id appreciate it. Thanks.

youll get more responses if you post the actual code instead of the file people are to skeptical download anything in the first place and most people don't want to download source code that can easily fit on the webpage :P

First of all instead of writing out all those numbers on top i would put it in a loop by using a variable increment that variable and so forth Also to create a book of * use \n and . Make your life a lot easier. Don't have to type as much :). Easy to reuse you code.

Instead of using all those char arrays use string and getline() which should allow you to put in a delimiter to stop at.



setw() sets the field width of the next item only. So I don't think you should be having problems. Maybe you could explain the problem.

#include <iostream>

using namespace std;

int main()
{
	int j;
	for(int i=0; i<=5; i++)
	{
		for(j=0; j<=9; j++)
		{
			cout<<j;
		}
			j=0;
	}

	return 0;
}

Do something like this with the remainder of the *. Make your code look less clutter and easier to read :).

thanks for the for loop idea i implemented that, but basically for the getline i want to use that and the string just read like 20 spaces including blankspace after the word if thats possible. Because right now my input file has names of different sizes, so when i go to setw the next word they end up not equal in spaceing like:

Student name: Total Points: Program Avg:
Snow White 600 82.00
Sleeping Beauty 590 81.00

and i cant setw different on each line because it's in a loop.

use getline till end of line using \n and then you can create substrings with delimeters.
maybe use getline() in conjunction with stream operators such as >> since you want to read in integers or numbers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.