the real code is this,
Code:
//Author: Gavinn Niroopan//
//Program Name: ngsummary.h//
//Revision Date: 2002-10-11//
//Explanation: to use variables and loopibf structures display a summary,the following assignment will demonstrate a program structure, code layout and use logic structure//
#include <iostream.h> //allows cout statement//
#include <iomanip.h> //allows decimal formatting, setiosflags()//
#include <conio.h> //allows clrscr() and getch()//
#include <string.h> //allows strcpy()//
#include <time.h> //allows the call of time function//
#include <stdio.h> //allows printf statement//
int main(void)
{
int studcountmax, year;
double term1, term2, studaverage, classtotal;
time_t t=time(NULL); //time function//
//Fowler Statement//
setiosflags(ios::right|ios::fixed);
//Will display the time//
cout <<setw(79)<<ctime(&t)<<endl;
cout<<setw(79)<<"Gavinn Niroopan"<<endl;
cout<<setw(79)<<"2002-10-11"<<endl;
cout<<setw(79)<<"Mr. Slack"<<endl;
cout<<setw(79)<<"ICS 3MO-A"<<endl;
gotoxy(32,8); //moves cursor to location (x,y) on screen//
cout<<"Summary Program"<<endl;
gotoxy(32,9);
cout<<"~~~~~~~~~~~~~~~"<<endl;
//"for" loop for spacing//
for(int i= 1;i <=6;i++)
cout<<endl;
cout<<"Explanation:"<<endl;
cout<<"~~~~~~~~~~~"<<endl<<endl;
cout<<"\tTo create a program which will use variables and looping structures"<<endl;
cout<<"\tto display a summary sheet. The following assignment will demonstrate"<<endl;
cout<<"\ta program structure, code layout and use logic structures. The program"<<endl;
cout<<"\tThe program will use data derived from the user and date acquired from"<<endl;
cout<<"\the system at time of execution."<<endl;
getch(); //Pause screen//
clrscr(); //clear screen//
cout<<ctime(&t)<<endl<<endl;
gotoxy(29,4);
cout<<"Class Summary Analysis"<<endl;
gotoxy(29,5);
cout<<"~~~~~~~~~~~~~~~~~~~~~~"<<endl<<endl;
cout<<"\tHow many students are being processed: ";
cin>>studcountmax;
cout<<"\tWhat school year is being processed: ";
cin>>year;
clrscr(); //clear screen//
for(int studcount=1;studcount<=studcountmax;studcount++)
{
cout<<ctime(&t)<<endl<<endl;
gotoxy(26,4);
cout<<"Student Term Evaluation Record"<<endl;
gotoxy(26,5);
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl<<endl;
cout<<"\t\tEnter the 1st term mark: - ";
cin>>term1;
cout<<"\t\tEnter the 2nd term mark: - ";
cin>>term2;
studaverage = (term1 + term2)/2;
classtotal = classtotal + studaverage;
// redirect standard output to a file //
if (freopen("OPEN.txt", "a", stdout)== NULL)
fprintf(stderr, "error redirecting stdout\n");
//this output will go to a file //
{
printf("Student ",studcount,"%f",studaverage);
cout<<endl;
}
// close the standard output stream //
fclose(stdout);
clrscr();
}
getch();
return 0;
}
I want it to look like this in the txt file;
student 1 63.00%
student 2 78.00%
etc. but its not working properly.