April 4th, 2003, 01:26 AM
|
#5 (permalink)
|
| Senior Member
Join Date: May 2002 Location: Rocky Mountain High
Posts: 613
|
The problem your getting now, assuming you copied the code EXACTLY like it was written in the post you linked to, is what's called a scope resolution error. When I retyped in the program to see if I could compile it, I automatically firxed that error out of habit and forgot I did so Code: #include <iostream.h>
int code[100];
char disp;
main()
{
for(int a=0; a<=12; a++)
{
cout << "enter code \n";
cin >> code[a];
}
cout <<endl<<endl;
//Look here, you'll notice I redeclared "a" as an int
for(int a=0; a<=12; a++)
{
if(code[a]>22)
{code[a]=code[a]-23;
disp= code[a] + 64;}
else{
disp= code[a] + 68;}
cout << disp << " ";
cout<<endl;
return 0;
} The problem that shows up refers to line 19, which is after the comment I added. You'll notice in the code that I compiled, there is another "int" before "a=0". This is because right now, "a" is only scoped in the first "for" loop (located in line 11, which refers to the second line of the error).
So just try adding that "int" in front of a=0 in the second "for" statement (line 19)  |
| |