Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

British flag

Status
Not open for further replies.

rwese3

Programmer
Feb 17, 2001
3
US
I am having a problem with my class and I need some help. We were assigned to make a british flag graphic without the border. I cannot use an array to create a field for the graphics because we haven't learned that yet. I must use things like gotoxy (x,y) , for, if, end, else, and goto statements, you know, elementary stuff. Supposedly this gotoxy (x,y) statement will help me solve the problem of creating one graphic line like the \ diagonal and being able to go back to the first line to start the second graphic line of the flag. What the teacher said was basically the logic will go as follows: declare the variables with the for statement, then goto the first x value (0) and when y=x, print an ASCII character. Then use the \n to go to the next line and repeat. I figure to use a 20 x 20 field to keep it simple and square. I have the following code so far and am sure some of the lines are either out of order, improperly syntaxed or not necessary.
#include<iostream.h>
#include<conio.h>
int x;
int y;
void main()
{
for(int x=0, y=0; x<20, y<20; x++, y++)
if (x==20) goto done;
gotoxy(x,y);
cout << &quot;\x03&quot; &quot;\n&quot;;
done:
cin >> &quot;&quot;;
return;
}
this is my best stab at it so far and my compiler is called Quincy 97 and is bound to be coming up with more errors than if it were running on the Borland's at School, but it is coming up with the following errors:
assignment5.cpp:12: warning: implicit declaration of function `int gotoxy(...)'
assignment5.cpp:12: warning: name lookup of `x' changed for new ANSI `for' scoping
assignment5.cpp:10: warning: using obsolete binding at `x'
assignment5.cpp:12: warning: name lookup of `y' changed for new ANSI `for' scoping
assignment5.cpp:10: warning: using obsolete binding at `y'
assignment5.cpp:16: warning: `return' with no value, in function returning non-void
Any help would be appreciated greatly.
Richard W.
 
#include<iostream.h>
#include<conio.h>
int x;
int y;
void main()
{
for(int x=0, y=0; x<20, y<20; x++, y++)
{
gotoxy(x,y);
cout << &quot;\x03&quot; &quot;\n&quot;;
}
cin >> &quot;&quot;;
}

this error &quot;assignment5.cpp:12: warning: name lookup of `x' changed for new ANSI `for' scoping&quot; is coming from the two declarations you have for x and y. Because you have the int x and int y at the beginning of the program, you don't need to specify int in the for loop.. eg. for (x = 0, y = 0, etc...)

Remove the &quot;return;&quot; to eliminate this error -> &quot;assignment5.cpp:16: warning: `return' with no value, in function returning non-void&quot;


You shouldn't need this since you have the loop...
if (x==20) goto done

for this error &quot;assignment5.cpp:12: warning: implicit declaration of function `int gotoxy(...)'&quot; you'll have to look up in Quincy 97's help as to whether or not gotoxy is supported. If memory serves, gotoxy is a borland specific statement that is in a file called &quot;graphics.h&quot;. Visual C++ 6 (which I have) does not include this function.

Good luck... I hope this helps a little to get you further along...


 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top