1、a libc source codes on windows by cc group(xichen2, xuchen); windows平台下面的libc库源代码, cc组合编写;
2、因为C库的内容很多,目前必须依然依赖windows的C库,正在逐步摆脱依赖关系,最终实现只调用windows API.
3、工程使用VS2010打开;
4、参考如下代码:
Microsoft Visual Studio 10.0安装目录下:
VC\crt\src
5、代码是线程不安全的;查看或者下载地址:
http://code.google.com/p/windows-libc/
或者在google code中搜索 windows-libc
6、代码示例:
实现类似strtok函数功能的函数:
view plain
char * __cdecl cc_strtok(
char *str,
const char *delim
)
{
static char *last;
char *strCp = str; // backup the str head pointer
int hasFoundToken = 0;
if(!str)
{
strCp = str = last; // if str is NULL, update the str head pointer
}
while(*str)
{
if(cc_strchr(delim, *str)) // if found the delims in the str
{
++str;
if(!hasFoundToken)
{
++strCp;
}
else // if hasFoundToken
{
if(strCp != str)
break;
}
continue;
}
hasFoundToken = 1;
++str;
}
if(!*str)
return NULL;
*(str - 1) = '\0'; // end the token by null character
last = str; // save the last pointer
return strCp;
}
转载于:https://www.cnblogs.com/ccteam/archive/2011/09/04/2166524.html