I have two instances of the following code just built in two different projects on the same visual studio package on the same machine at approximately the same time. On the first project the code compiled and ran with no problems.
I created a new project and entered the code but the second attempt failed giving E0349 errors 'no operator ">>" and "<<" matchs these operands along with a number of other errors.
I can find no references to this behavior on the internet or any of my manuals.
I have retyped the errant code numerous times with the same results.
I have Copied and pasted the code into the second window, still fails.
I created a third project and pasted the code. Still fails
I suspect I am making at least one stupid mistake but I cannot find it.
Any help you could give would be greatly appreciated.
Both instances of the code look identical to me down to the line counts.
I have a screen shot of both windows side by side if that would help.
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include "stdafx.h"
#include <iostream>
struct PlayerInfo
{
int skill_level;
string name;
};
using namespace std;
int main()
{
// like normal variable types, you can make arrays of structures
PlayerInfo players[5];
for (int i = 0; i < 5; i++)
{
cout << "Please enter the name for player : " << i << '\n';
// first access the element of the array, using normal
// array syntax; then access the field of the structure
// using the '.' syntax
cin >> players[i].name;
cout << "Please enter the skill level for " << players[i].name << '\n';
cin >> players[i].skill_level;
}
for (int i = 0; i < 5; ++i)
{
cout << players[i].name << " is at skill level " << players[i].skill_level << '\n';
}
}
|