Learning diary (string handling functions Tips strxxx)

Today looked at the teacher's experiment code, it took about an hour to read, and then annotate, when the last run, the program inexplicable crashes, and spent half an hour checking program, and finally found to be a function strcmp error, the program can not run, the teacher did not find it? Really angry! ! !

Cause: string handling functions strxxx a series of standard C library functions, parameter passing NULL will cause the program to crash.

#include <stdio.h> 
#include < String .h>
 int main () 
{ 
  char S [ 10 ]; 
  strlen (NULL);   // program crashes 
  strcmp (S, NULL);   // program crashes 
  strcpy (s, NULL );   // program crashes 
  return  0 ;     
}

 

Guess you like

Origin www.cnblogs.com/zhi321/p/11566889.html