# Thread: A little problem

1. ## A little problem

Hello, I need little help with this. Basically what I want for the program to do for me is to show on the graphic window n number of circles with the positions i give it [a,b in my situation (that is x.y)]

I made this and it does print out the first circle but when ever I want to enter the positions for the 2nd circle it closes

Code:
```void circle(int a,int b);

int main()
{
int a,b;
int n,i;

openwindow();
printf("Number of circles\n");

scanf("%d", &n);

if(n<=0)
{
printf("Please enter a number higher than 0\n");
getch();
return 0;
}
if (n>3)
{
printf("The number of circles is to high\n");
getch();

return 0;
}

printf("Enter the position of the circle/s\n");

for(i=0; i<n; i++);
{
scanf("%d %d", &a,&b);       // Im not sure how to fix this .. what ever i try I get errors like no pointer to "i"?
}

circle(a,b);

getch();

return 0;
}

void circle(int a,int b)
{
circle(a,b,200);
}```

I would like if someone could give me a hint how to fix the problem I have, iv been trying to fix this for hours but i get an even more complicated problem after.

2. You should not have a semicolon at the end of for(i=0; i<n; i++);

3. Thank you! I did remove the semicolon and it doesn't close anymore at the 2nd input
How ever it prints out in the graphic window only one circle

example what it does

*enter the number of crircles
->2
*enter the position of the circle
x->0
y->0
x->100 [ it prints out only the last circle while skipping the first one ]
y->100

Iv been trying many things but the error list only gets flooded ...

4. Look carefully at your scope
Code:
```  for(i=0; i<n; i++)
{
scanf("%d %d", &a,&b);       // Im not sure how to fix this .. what ever i try I get errors like no pointer to "i"?
}

//!! this is NOT in the loop, so you only get the LAST values stored in a and b
circle(a,b);```

> void circle(int a,int b)
> circle(a,b,200);
C doesn't do function overloading, so you need to be compiling this with a C++ compiler.

5. Thanks Salem!!!!
I finally did it !!!

After 2 hours [ I wish that I could function better ] of trying to do it I did it.

I'm not sure if I could tweak the code and make it more simple but it doesn't matter because it does what I wanted it to do at the start.

Code:
```void getcircle(int *xp,int *yp);
void circle(int x,int y);

int main()
{
int n;
int x,y;
int i=0;
openwindow();

scanf("%d",&n);

while (i<n)
{
i++;
getcircle(&x,&y);
circle(x,y);
}
}

void circle(int x, int y)
{
circle(x,y,200);
}

void getcircle(int *xp, int *yp)
{
scanf("%d %d", &*xp,&*yp);
}```

6. I suggest changing this line
Code:
`scanf("%d %d", &*xp,&*yp);`
to
Code:
`scanf("%d %d", xp,yp);`
Tim S.

Popular pages Recent additions