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函數功能的函數:
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;}
7、歡迎大家提出寶貴的意見,虛心接受。