Help With First C++ program?

Discussion in 'C Programming' started by Ranger's Sweetheart, Sep 15, 2011.

  1. Ranger's Sweetheart

    Ranger's Sweetheart

    Joined:
    Sep 15, 2011
    Messages:
    1
    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) << " ";
    }
    Ranger's Sweetheart, Sep 15, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. matt
    Replies:
    9
    Views:
    414
    Andrew Thompson
    Oct 27, 2004
  2. Daniel
    Replies:
    0
    Views:
    307
    Daniel
    Apr 25, 2004
  3. Tim Golden

    RE: my first program- List Box help?

    Tim Golden, Apr 26, 2004, in forum: Python
    Replies:
    0
    Views:
    415
    Tim Golden
    Apr 26, 2004
  4. aToaster
    Replies:
    2
    Views:
    376
    Tony Clarke
    Aug 22, 2004
  5. Christopher M. Lusardi
    Replies:
    3
    Views:
    186
    Alan J. Flavell
    Oct 19, 2003
Loading...

Share This Page