Jessie (jessiesk) wrote,

  • Mood:

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 {[1]);
cout<<"Cannot open input file. Program terminates!"<<endl; return 1; } readFirstLineInputFile(infile); initilizeAllVariables(); readStudentsAnswers(infile); computeScores(); writeOutput(outfile); cleanUpMemory(); } } I suck at programming.... :: grumble ::

  • Update!

    Yeah, Jess lives. if you can call it that, that is. One more week then I'll probably shine a li'll light on what's been up and down and around in…

  • Playing with Photoshop in class

    Ahem... like a li'll 2 year old kid eh? "yay i can use Photoshop and do simple stuff"

  • Photoshop Smiley

    OKay it's no masterpiece, but:

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded