Notices
The Basement Non-Honda/Acura discussion. Content should be tasteful and "primetime" safe.

need some help on hw.....C++ related.

Thread Tools
 
Old 02-28-2004, 01:42 PM
  #1  
aznd000d
yoooooooooooo
Thread Starter
 
aznd000d's Avatar
 
Join Date: Oct 2003
Location: Riverside, CA
Posts: 148
Likes: 0
Received 0 Likes on 0 Posts
Default need some help on hw.....C++ related.

this "structure" chapter is so confusing. so i'm wondering if anyone can help me out.

am I coding this right so far?
Code:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

struct date
{
int day;
int month;
int year;
};

struct studentinfo
{
int SID;
double GPA;
int total_units;
int current_units;
};

void input (date& DOB, date& grad_date);

int main ()
{

date DOB;
date grad_date;

ifstream fin;
ofstream fout;

fin.open("raw.txt");
   if (fin.fail())
   {
   cout << "File 'raw.txt' failed to open";
   exit (1);
   }

input (DOB, grad_date);

}


void input (date& DOB, date& grad_date)
{
fin >> studentinfo.SID
    >> studentinfo.GPA
    >> date.DOB.day
    >> date.DOB.month
    >> date.DOB.year
    >> studentinfo.total_units
    >> studentinfo.current_units
    >> date.grad_date.day
    >> date.grad_date.month
    >> date.grad_date.year;
}
i gotta read in from this file:

Code:
1234 3.5 4 9 1985 28 16 6 15 2009
2345 3.25 2 8 1980 96 12 6 12 2004
3456 2.96 12 8 1983 72 13 6 13 2005
4567 4.0 9 27 1975 62 18 12 16 2005
5678 3.65 8 16 1982 16 16 4 3 2009
and output this, which I haven't done:

Code:
 SID   GPA      DOB      Total Units  Current Units    Grad Date
----  ----  ----------   -----------  -------------   ----------
1234  3.50   4/ 9/1985       28            16          6/15/2009
2345  3.25   2/ 8/1980       96            12          6/12/2004
3456  2.96  12/ 8/1983       72            13          6/13/2005
4567  4.00   9/27/1975       62            18         12/16/2005
5678  3.65   8/16/1982       16            16          4/ 3/2009
am I doign my "fin" correctly?
Old 02-28-2004, 01:50 PM
  #2  
benjamin
Stuff and things.
 
benjamin's Avatar
 
Join Date: Dec 2003
Location: New York
Posts: 1,972
Likes: 0
Received 0 Likes on 0 Posts
Default try finishing the project

Finish the project. If you get compiling errors, read them. If you can't fix the errors, then get to know your professor by asking for help.
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
flipped cracka
The Basement
36
08-20-2003 05:29 PM
SaviouR
The Basement
7
06-02-2003 08:48 PM
Sadiztik-R
The Basement
1
05-20-2003 03:53 PM
Samson
The Basement
10
04-30-2003 08:26 PM



Quick Reply: need some help on hw.....C++ related.



All times are GMT -8. The time now is 07:44 PM.