Home > Back-end >  STRCMP function abnormal
STRCMP function abnormal

Time:09-17

Unable to run STRCMP function

CodePudding user response:

A no initialization,
A=(char *) malloc (sizeof (char) * 20);

CodePudding user response:

reference 1/f, the truth is more important than right or wrong response:
a initialization,
A=(char *) malloc (sizeof (char) * 20);

Still can't run the

CodePudding user response:

The name is not assigned space, to name [100]]

CodePudding user response:

Feeling is not the space allocation problem, can output stu1 [g]. The value of the name

CodePudding user response:

The scanf (" % s ", & amp; A); Don't use address-of operator & amp;

CodePudding user response:

Thank you, the original is with malloc initialization first and then the scanf that there is no & amp;

CodePudding user response:

A and name are wild pointer, for wild pointer using the result is undefined
  • Related