July 7th, 2004

Doctor Who: 10 - blue smirk look

Group meeting and... C++ stuff

Gak! Can't they talk about anything other than guys, clothes, drinking .. aiye... I was like :: leaf through books nonchalantly, calmly ignoring them, only looking up to throw a glare if they get too loud::

Dang C++, majorly stuck in a couple of places...the more I think about it logically, it makes sense, but then I forget to include an essential element of the program and it all goes boom... :: rip hair out::

#include < stdio.h >
#include < stdlib.h >
#include < iostream.h >
#include < fstream.h >
#include < string.h >

//------------------------ Global data definitions -----------------------------
struct studentInfo{
char* studentId;
char* answers;
int score;
int wrongAnswers;
int correctAnswers;
char grade;
};

studentInfo* data;
int noOfStudents;
int noOfQuestions;
char* examAnswers;
//---------------------------------------------------------------------------
void initilizeAllVariables(){
data = new studentInfo[noOfStudents];
for (int i=0; i< noOfStudents;i++){
data[i].studentId = new char[8];
data[i].answers = new char[noOfQuestions];
data[i].score = 0;
data[i].wrongAnswers =0;
data[i].correctAnswers =0;
}
//---------------------------------------------------------------------------
void cleanUpMemory(){
// Clean up all the memory allocated. This function is called when the
// program is done
}
//---------------------------------------------------------------------------
void readFirstLineInputFile(ifstream& ins){
ins >> noOfStudents;
ins >> noOfQuestions;
int i;
examAnswers = new char [noOfQuestions];
for (i=0; i< noOfQuestions; i++)
ins >> examAnswers[i];
}
//---------------------------------------------------------------------------
void readStudentsAnswers(ifstream& ins){
// Read the rest of the file and store the answers of each students
}
//---------------------------------------------------------------------------
void computeScores(){
// Compute the score for each student
}
//---------------------------------------------------------------------------
char computeExamGrade(int score){
// This method return the corresponding grade for each score
}
//---------------------------------------------------------------------------
void writeOutput(ofstream& outs){
// Open the output file
// Write statistics and close the file
// The file name should be result.txt and is stored in
// the current directory
}
//---------------------------------------------------------------------------

int main(int argc, char* argv[])
{
ifstream infile;
ofstream outfile;

if (argc < 2){
cout << "input file name was not specified in the command line!" << endl;
cout << "the correct way to execute the program is as follows:" << endl;
cout << "\t\t Programname inputfilename \n";
return 1;
}else {

infile.open(argv[1]);
if(!infile)
{
cout<<"Cannot open input file. Program terminates!"<<endl; return 1; } readFirstLineInputFile(infile); initilizeAllVariables(); readStudentsAnswers(infile); computeScores(); writeOutput(outfile); cleanUpMemory(); } } I suck at programming.... :: grumble ::
  • Current Mood
    frustrated frustrated
Doctor Who: 10 - blue smirk look

Blargh

I'm gonna talk to him tomorrow regarding that C++ proggy and how exactly we're supposed to do this.. right now it makes sense in places, makes half sense when I think about what to do with some of the functions, but that's about it.. aiy.. yeah I'm not that good with writing programs as I am with getting the theory bits of it....

back being an annoyance...rather that spot on the right side....got a cramp in my wrist today in class, was so bad I dropped the pen when I was taking down notes in class... x_x; hope it's not trying to tell me I gotta wear the dang wrist support again, I hate that thing.... :: grumble ::
  • Current Mood
    uncomfortable uncomfortable