Question: This C++ code is throwing 29 errors. It is mostly undeclared errors, but eveything seems to be defined. Please help: CODE #include #include #include #include
This C++ code is throwing 29 errors. It is mostly undeclared errors, but eveything seems to be defined. Please help:
CODE
#include
using namespace std;
//Main function int main() { int playerCount, roundCount; string name; int score, i, j;
//Reading number of players cout << " Number of players in the game? "; cin >> playerCount;
//Reading number of rounds cout << " Number of rounds to be played? "; cin >> roundCount;
//Opening file for writing fstream fout("cardGameRecord.txt", ios::out);
//Writing to file fout << " Player Names: ";
cin.ignore();
//Reading player names for (i = 0; i //Writing name read to file fout << name << " \t "; } //Reading scores for each round for (j = 1; j <= roundCount; j++) { //Writing header fout << " Round " << j << " scores : "; cout << " Round " << j << " scores : "; //Reading scores of each player for each round: for (i = 1; i <= playerCount; i++) { //Reading player score cout << " Enter player " << i << " score: "; cin >> score; //Writing score to file fout << score << " \t "; } } //Closing file fout.close(); //Writing line to console cout << " Data has been written to file successfully..... "; return 0; } ERRORS Error C2065 'string': undeclared identifier 15 Error C2146 syntax error: missing ';' before identifier 'name' 15 Error C2065 'name': undeclared identifier 15 Error C2065 'cout': undeclared identifier 19 Severity Code Description Project File Line Suppression State Error C2065 'cin': undeclared identifier 20 Error C2065 'cout': undeclared identifier 23 Error C2065 'cin': undeclared identifier 24 Error C2065 'fstream': undeclared identifier 27 Error C2146 syntax error: missing ';' before identifier 'fout' 27 Error C2653 'ios': is not a class or namespace name 27 Error C2065 'out': undeclared identifier 27 Error C3861 'fout': identifier not found 27 Error C2065 'fout': undeclared identifier 30 Error C2065 'cin': undeclared identifier 32 Error C2228 left of '.ignore' must have class/struct/union 32 Error C2065 'cout': undeclared identifier 38 Error C2065 'cin': undeclared identifier 39 Error C2065 'name': undeclared identifier 39 Error C3861 'getline': identifier not found 39 Error C2065 'fout': undeclared identifier 42 Error C2065 'name': undeclared identifier 42 Error C2065 'fout': undeclared identifier 49 Error C2065 'cout': undeclared identifier 50 Error C2065 'cout': undeclared identifier 56 Error C2065 'cin': undeclared identifier 57 Error C2065 'fout': undeclared identifier 60 Error C2065 'fout': undeclared identifier 65 Error C2228 left of '.close' must have class/struct/union 65 Error C2065 'cout': undeclared identifier 68
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
