Home > Back-end >  The novice consult
The novice consult

Time:11-23

Input the id is the first step to obtain information is stuck

CodePudding user response:

Where is the card?
Is not your output effect?
You should change the print to
Printf (" the man's birthday is: ");
For (I=6; i<14. I++)
Printf (" % c ", id [I]);

CodePudding user response:

reference 1st floor qybao response:
where the card?
Is not your output effect?
You should change the print to
Printf (" the man's birthday is: ");
For (I=6; i<14. I++)
Printf (" % c ", id [I]);

Still won't do ah, I think is a problem of the string

CodePudding user response:

The string end finally multiple
So your id is defined as a char id [19]
Scanf_s (" % s ", id, sizeof (id));

CodePudding user response:

Scanf_s (" % s ", id, 18) input up to 17 characters at this time, the last one to deposit '\ 0',
If the input number more than, you will get out of the anomaly, can monitor the id, see what is specific value

CodePudding user response:

Scanf_s already specified length, there will be no cross-border, scanf_s safer than the scanf, in no more than the original poster is safety input length,

The host's problems should not card, but the result of the input do not match the actual, the last character no input (because the store is used as a '\ 0'),

CodePudding user response:

Scanf_s will at the end of your input additional a '\ 0',
When found enough deposit, will be directly in the first character '\ 0' written at the back of the character & amp; Id [6] these has no meaning
  • Related