Home > Back-end >  C program to debug the interrupt processing method
C program to debug the interrupt processing method

Time:09-22

#include
Int main ()
{
Struct Stu {
Char name [100].
char sex;
int age;
float score;
Char addr [100].
} stu1 stu2;
Scanf_s (" % s % c % d % f, % s ", stu1. Name, & amp; Stu1 sex, & amp; Stu1. Age, & amp; Stu1 score, & amp; Stu1. Addr);
Scanf_s (" % s % c % d % f, % s ", stu2. Name, & amp; Stu2 sex, & amp; Stu2. Age, & amp; Stu2 score, & amp; Stu2. Addr);
If (stu1. Score & gt; Stu2. Score)
Printf (" % s % c % d % f, % s ", stu1. Name, stu1. Sex, stu1. Age, stu1. Score, stu1. Addr);
If (stu1. Score & lt; Stu2. Score)
Printf (" % s % c % d % f, % s ", stu2. Name, stu2. Sex, stu2. Age, stu2. Score, stu2. Addr);
If (stu1. Score==stu2. Score)
{
Printf (" % s % c % d % f, % s ", stu1. Name, stu1. Sex, stu1. Age, stu1. Score, stu1. Addr);
Printf (" % s % c % d % f, % s ", stu2. Name, stu2. Sex, stu2. Age, stu2. Score, stu2. Addr);
}
return 0;
}
0 xfefefefe in untreated exception (in Project51. Exe) : 0 xc00001a5: detect invalid exception handling routines, (parameters: 0 x00000003),
Seek advice

CodePudding user response:

scanf_s () is used to read the string, you must provide a number to indicate how many characters, most read in order to prevent overflow,
Scanf_s (" % s ", buf, 5);//says most read four characters, because buf should put [4] '\ 0'

CodePudding user response:

reference dared to 1/f, 001 response:
scanf_s () is used to read the string, you must provide a number to indicate how many characters, most read in order to prevent overflow,
Scanf_s (" % s ", buf, 5);//says most read four characters, because buf should put [4] '\ 0'

I then display an error

CodePudding user response:

Use the scanf is bad

CodePudding user response:

reference 3/f, 5250 response:
with the scanf bad?

VS complains

CodePudding user response:

Scanf_s is a function of v need, compared the scanf is high safety, but need to pay attention to the % c, % s, you need to specify the length that is some difference between scanf_s and the scanf

CodePudding user response:

reference 5 building self-confidence boy reply:
scanf_s is a function of v need, compared the scanf is high safety, but need to pay attention to the % c, % s need to specify the length, this also is some difference of scanf_s and the scanf

I see, three grams of oil
  • Related