need some help on hw.....C++ related.
#1
yoooooooooooo
Thread Starter
Join Date: Oct 2003
Location: Riverside, CA
Posts: 148
Likes: 0
Received 0 Likes
on
0 Posts
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?
i gotta read in from this file:
and output this, which I haven't done:
am I doign my "fin" correctly?
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; }
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
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
#2
Stuff and things.
Join Date: Dec 2003
Location: New York
Posts: 1,972
Likes: 0
Received 0 Likes
on
0 Posts
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.
Thread
Thread Starter
Forum
Replies
Last Post