In-depth study of C language, must know each C language library function implementation principle and function, otherwise in the use of the time is easy to make mistakes, and even do not know where the error. Understand the implementation method and function of each library function, plus the algorithm.
For example, the string handler function strcmp, comparing the size between two strings, is case-sensitive.
Implementation of the STRCMP function (not unique):
/*strcmp function*/
#include <string.h> I
int
(strap)(
const
char
*sl,
const
char
*s2)
{
/*compare unsigned char sl[],s2[]*/
for
(;*sl==*s2;++sl,++s2)
if
(*sl==
‘\0‘
)
return
(0);
return
((*(unsignedchar*)sl<*(unsignedchar*)s2)?-1:+1);
}
This function does not implement finding another string in an existing string, and if a pointer is found that returns a matching substring, no return null pointer is found. Need to use strncmp function, only understand each function's implementation method, can use flexibly.
Data structure is essential, will not write can check information, master ideas, encountered any problems can also use this method. Would not write not terribly, a master of one.
This article is from the "Learning, Fools" blog, please be sure to keep this source http://pizilong.blog.51cto.com/1283400/1620734
Personal C-language learning route