#include <stdio.h>
int main() {
struct cerchio c1, c2;
float distanza;
char k;
//input del centro del primo cerchio
printf("Enter the coordinate x of the first circle's center: ");
scanf("%f", &c1.centro.x);
printf("Enter the coordinate y of the first circle's center: ");
scanf("%f", &c1.centro.y);
//input del raggio del cerchio
printf("Enter the circle's radius: ");
scanf("%f", &c1.raggio);
printf("The first circle's center is: (%.2f, %.2f)
", c1.centro.x, c1.centro.y);
printf("Do you want to move this circle? y/n
");
//Here is the problem <-------------
scanf("%s", &k);
if(k=='y'){
moveCircle(&c1);
printf("Now the circle's center is: (%.2f, %.2f)
", c1.centro.x, c1.centro.y);
}
}
In the scanf under the comment //here is the problem if i put %c the program end. The input doesn't work! If i put %s the program work perfectly. Why? I have declared the variable k char!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…