- Joined
- Sep 15, 2011
- Messages
- 1
- Reaction score
- 0
Hi, I'm very new to C++ and computer programming in general. I'm sorry if this is an annoying question or a terrible program. I am fairly sure the logic of my program is right and I just have a bunch of syntax errors. Can anyone help me fix them? I've fixed all I can figure out how to fix, and my program looks like this:
#include <conio.h>
#include <iomanip>
#include <iostream>
#include <fstream>
using namespace std;
void heading();
void printTotals();
void getRecord(char snum, char fname, char lname, char course, int credits);
void write_to_file(char snum,char fullName,char course,int credits);
int totStud;
int totCredit;
int stCredit;
char hnum;
ifstream infile;
ofstream outfile;
int main()
{infile.open("Program2.txt");
outfile.open("Program2.rpt");
heading();
while (!infile.eof())
getRecord();
hnum=snum;
{if (snum==hnum)
strcpy(fullName, fname);
strcat(fullName, " ");
strcat(fullName,lname);
write_to_file(snum,fullName,course,credits);
totCredit += credits;
stCredit += 1;
else
outfile<<set(34)<<" "<<set(14)<<"Student Total"<<set(10)<<" "<<set(5)<< stCredit
totStud +=1;
stCredit=0;
hnum=snum; endl
outfile<< "Total Students = "<< totStud endl;
outfile<< "Total Credits = "<< totCredit; endl;
outfile.close()
}
}
void heading()
{
outfile << "NUMBER STUDENT NAME COURSE CREDITS TOTAL CR" << endl;
}
void printTotals()
{
}
void getRecord(char snum, char fname, char lname, char course, int credits)
{
infile >> snum >> fname >> lname >> course >> credits;
}
void write_to_file(char snum, char fullName, char course, int credits,int stCredit)
{
outfile<< setw(10) << snum << setw(5) << " "
<< setw(15) << fullName << setw(5) << " "
<< setw(9) << course << setw(5) << " "
<< setw(6) << credits << setw(5) << " ";
}
#include <conio.h>
#include <iomanip>
#include <iostream>
#include <fstream>
using namespace std;
void heading();
void printTotals();
void getRecord(char snum, char fname, char lname, char course, int credits);
void write_to_file(char snum,char fullName,char course,int credits);
int totStud;
int totCredit;
int stCredit;
char hnum;
ifstream infile;
ofstream outfile;
int main()
{infile.open("Program2.txt");
outfile.open("Program2.rpt");
heading();
while (!infile.eof())
getRecord();
hnum=snum;
{if (snum==hnum)
strcpy(fullName, fname);
strcat(fullName, " ");
strcat(fullName,lname);
write_to_file(snum,fullName,course,credits);
totCredit += credits;
stCredit += 1;
else
outfile<<set(34)<<" "<<set(14)<<"Student Total"<<set(10)<<" "<<set(5)<< stCredit
totStud +=1;
stCredit=0;
hnum=snum; endl
outfile<< "Total Students = "<< totStud endl;
outfile<< "Total Credits = "<< totCredit; endl;
outfile.close()
}
}
void heading()
{
outfile << "NUMBER STUDENT NAME COURSE CREDITS TOTAL CR" << endl;
}
void printTotals()
{
}
void getRecord(char snum, char fname, char lname, char course, int credits)
{
infile >> snum >> fname >> lname >> course >> credits;
}
void write_to_file(char snum, char fullName, char course, int credits,int stCredit)
{
outfile<< setw(10) << snum << setw(5) << " "
<< setw(15) << fullName << setw(5) << " "
<< setw(9) << course << setw(5) << " "
<< setw(6) << credits << setw(5) << " ";
}