As a first year c++ coder, i was intreaged by the language as soon as i sat down in the classroom. However, on a school assighnment,I have come upon an error that is unfamiliar to me. The assighnment was to simplifly a program that was far too complex. The end result was a simple four function calculator. I typed up the code and when i compiled it i came across an error called a parse error, one that we hadnt reviewed in the classroom. My code was as follows:
#include <iostream.h>
#include <stdlib.h>
main()
{
float b, a;
float c;
char x[2];
cout<< "What two numbers would you like to use the operation on?";
cin>>a>>b;
cout<< "What is the operation? ( [+] or [-] or [*] or [/] )";
cin.get(x, 2);
cin.ignore(80, '\n');
c=a[x]b;
cout << "Your answer is " <<c<<'\n' ;
system("PAUSE");
return 0;
}
<< moderator edit: added code tags: [code][/code] >>
The errors showed up as follows:
(line 17) parse error before `='
after hours of trying to correct the error, i typed up an alternate method and turned it in for the grade. But this error still confuses me.
Please Help!!!