galgal
galgal

Reputation: 21

about C and eclipse - scanf

When I try to use scanf

int main() {

    int x1,x2,x3,y1,y2,y3;

    printf("Enter 3 pairs of positive integers separated by spaces:\n");

    scanf("%u %u %u %u %u %u", &x1, &y1, &x2, &y2, &x3, &y3);

I get the program running, like for an input. Then I put the input, but it prints the "enter 3 pairs..." and does nothing

why is that?

Upvotes: 0

Views: 239

Answers (3)

Trevor Arjeski
Trevor Arjeski

Reputation: 2168

You might find it more convenient to use fgets instead of scanf. The eclipse terminal is a little funky.

Refer to this post

Upvotes: 0

md5
md5

Reputation: 23709

Maybe you have to enter values; it is the goal of scanf.

By the way, your program contains an undefined behavior : %u mismatchs with int pointers. Use rather %d/%i format in printf. An other solution is to declare your variables as unsigned int type, to match with the printf format. Moreover, a part of your source code is missing.

Upvotes: 1

Aniket Inge
Aniket Inge

Reputation: 25705

%u is unsigned integer. %d or %i is signed integers. Please take care of these quirks and gotchas in C. Be careful to oblige to correct format specifiers.

Upvotes: 1

Related Questions