[am I just an idiot?] - Computers



Search Tech-Forums - link takes you to our Forum's search page.

Note: The following is only a text archive!


To view the actual forum discussion, please visit our website at http://www.tech-forums.net

Pages:1



am I just an idiot?

(Click here to view the original thread with full colors/images)



Posted by: deena

Okay, so I know I opened it up there....

but seriously guys..... I keep getting a syntax error over a stupid ";" and can't figure it out! I thought I was just tired last night, but I can't find it this morning either.

Anyone see it????

(just a note here....I am aware that I am not finished with this yet, I have more to write on it)


// January 25, 2007
// This exam grader program will read file contents and display a list
// of questions missed, with correct answer, total number missed
// percentage correct and if student passed or failed.

#include <iostream>
#include <vector>
#include <fstream>
using namespace std;


const int Array_Size = 2;
char correctAnswers[Array_Size];
char studentAnswers[Array_Size];
char name[20];
int count;
int question;
char answer;
fstream inputFile;
void getScores(char []);



main ()
{

//Get students name

cout <<"Enter student's name:\n";
cin >> name;
cout <<"Enter " << name <<"'s answers\n";

//Get scores

getScores(studentAnswers);

//read from file

inputFile.open("StudentAnswers.txt");

for (count = 0; count < Array_Size; count++)

inputFile << studentAnswers[Array_Size] << '\n';

inputFile.close();

inputFile.open("CorrectAnswers.txt");

for (count = 0; count < Array_Size; count++)

inputFile << correctAnswers[Array_Size] << '\n';

inputFile.close();

if (studentAnswers[Array_Size] != correctAnswers[Array_Size])
{
return false;
cout << "Incorrect, your answer was " << studentAnswers[Array_Size] << ",\n";
cout << "The correct answer is " << correctAnswers[Array_Size] <<;
}






return 0;
}

void getScores()
{
for (count = 0; count < Array_Size; count++)
{
cout << question <<":";
question++;
cin >> studentAnswers[answer];
answer++;
}
}



Posted by: jaeusm

Remove the last '<<' from the following line:
[CODE] cout << "The correct answer is " << correctAnswers[Array_Size] [B]<<[/B];[/CODE]

For future reference, when you post a problem, be sure to include the exact compiler error. Also, the code is a bit more readable if you use code tags in this forum :)



Posted by: deena

Thank you so much! I am so new to this I would not have found that. May I see an example of what code tags are? Really, I am very very new to this!!



Posted by: hillbillybob

[CODE]This is code[/CODE]

You can incase the text with the "code" tags in brackets. Be sure that you include opening and closing code tags. {CODE}{/CODE}, but use square brackets instead of curly brackets.

That would be the easiest for large blocks of code. If you are just adding one or two lines of code, you could click the # button when you are in the edit reply screen.



Posted by: deena

Thank you.





vBulletin Copyright ©2000 - 2003, Jelsoft Enterprises Limited.


PPC Management
vB Easy Archive Final - Created by Xenon