Home > Back-end >  C language array structure definition assignment why not
C language array structure definition assignment why not

Time:09-23

//will be simulated clock displayed on the screen
#include
#include
Struct clock
{
int hour;
Int minute;
Int second;
};

Typedef struct clock clock;

Int main ()
{
CLOCK c={0};
Scanf_s (" % d, % d, % d ", & amp; C. our, & amp; C. inute, & amp; C.s. econd);
If (c. our & lt; 24 & amp; & C. inute & lt; 60 & amp; & C.s. econd & lt; 60)
{
Printf (" % d: % d: % d ", c. our, c. inute, c.s. econd);
}
The else {
Printf (" error ");
}
System (" pause ");
return 0;
}

I input number three, but the second third number display is always 0, 0; It's not that I input the Numbers?

CodePudding user response:

Are the building when the input format is not right?
Because the original poster scanf_s format to enter a comma after each input numeric values, also pay attention to the comma is Chinese or English should also be consistent with a comma in scanf_s,
Give it a try again

CodePudding user response:

I tried no problem ah, how do you input input is?
The input should be "1, 2, 3" like this

CodePudding user response:

There is no problem! I tried what you use the IDE, how to input

CodePudding user response:

Result=scanf_s (" % d % % c % f c % s % s ", & amp; I, & amp; Fp, & amp; C, 1, & amp; Wc, 1, s., 81, ws, 81);
Scanf_s usage, unlike the scanf, is to bring bytes,
  • Related