📄 stdlibx.cpp
字号:
if (endptr) { if (tendptr) *endptr=const_cast<char*>(nptr+(tendptr-tnptr)); else *endptr=NULL; } return res;}unsigned long strtoul (const char *nptr,char **endptr,int ibase){ USES_CONVERSION; TCHAR* tnptr = A2T(nptr); TCHAR* tendptr = NULL; unsigned long res= _tcstoul(tnptr,&tendptr,ibase); if (endptr) { if (tendptr) *endptr=const_cast<char*>(nptr+(tendptr-tnptr)); else *endptr=NULL; } return res;}double strtod( const char *nptr, char **endptr ){ USES_CONVERSION; TCHAR* tnptr = A2T(nptr); TCHAR* tendptr = NULL; double res= _tcstod(tnptr,&tendptr); if (endptr) { if (tendptr) *endptr=const_cast<char*>(nptr+(tendptr-tnptr)); else *endptr=NULL; } return res;}#if _WIN32_WCE < 300const char * __cdecl strrchr (const char * string,int ch ){ char *start = (char *)string; while (*string++) /* find end of string */ ; /* search towards front */ while (--string != start && *string != (char)ch) ; if (*string == (char)ch) /* char found ? */ return( (char *)string ); return(NULL);}#endifsize_t strspn( const char *string, const char *strCharSet ){ const unsigned char *str = (const unsigned char*)string; const unsigned char *ctrl = (const unsigned char*)strCharSet; unsigned char map[32]; int count; /* Clear out bit map */ for (count=0; count<32; count++) map[count] = 0; /* Set bits in control map */ while (*ctrl) { map[*ctrl >> 3] |= (1 << (*ctrl & 7)); ctrl++; } /* 1st char NOT in control map stops search */ if (*str) { count=0; while (map[*str >> 3] & (1 << (*str & 7))) { count++; str++; } return(count); } return(0);}int stricmp( const char*string1, const char* string2 ){ USES_CONVERSION; return stricmp( (const unsigned short*) A2T(string1), (const char*) string2);}static void x64toa (unsigned __int64 val,char *buf,unsigned radix,int is_neg){ char *p; /* pointer to traverse string */ char *firstdig; /* pointer to first digit */ char temp; /* temp char */ unsigned digval; /* value of digit */ p = buf; if ( is_neg ) { *p++ = '-'; /* negative, so output '-' and negate */ val = (unsigned __int64)(-(__int64)val); } firstdig = p; /* save pointer to first digit */ do { digval = (unsigned) (val % radix); val /= radix; /* get next digit */ /* convert to ascii and store */ if (digval > 9) *p++ = (char) (digval - 10 + 'a'); /* a letter */ else *p++ = (char) (digval + '0'); /* a digit */ } while (val > 0); /* We now have the digit of the number in the buffer, but in reverse order. Thus we reverse them now. */ *p-- = '\0'; /* terminate string; p points to last digit */ do { temp = *p; *p = *firstdig; *firstdig = temp; /* swap *p and *firstdig */ --p; ++firstdig; /* advance to next two digits */ } while (firstdig < p); /* repeat until halfway */}/* Actual functions just call conversion helper with neg flag set correctly, and return pointer to buffer. */char * _i64toa (__int64 val,char *buf,int radix){ x64toa((unsigned __int64)val, buf, radix, (radix == 10 && val < 0)); return buf;}char * _ui64toa (unsigned __int64 val,char *buf,int radix){ x64toa(val, buf, radix, 0); return buf;}//#if _WIN32_WCE < 300__int64 _atoi64(const char *nptr){ int c; /* current char */ __int64 total; /* current total */ int sign; /* if '-', then negative, otherwise positive */ /* skip whitespace */ while ( isspace((int)(unsigned char)*nptr) ) ++nptr; c = (int)(unsigned char)*nptr++; sign = c; /* save sign indication */ if (c == '-' || c == '+') c = (int)(unsigned char)*nptr++; /* skip sign */ total = 0; while (isdigit(c)) { total = 10 * total + (c - '0'); /* accumulate digit */ c = (int)(unsigned char)*nptr++; /* get next char */ } if (sign == '-') return -total; else return total; /* return result, negated if necessary */}//#endifchar * _mktemp (char *temp){ char *string = temp; unsigned number; int letter = 'a'; int xcount = 0; int olderrno; _ASSERTE(temp != NULL); _ASSERTE(*temp != '\0'); number = (unsigned) GetCurrentProcess(); while (*string) string++;#ifndef _MBCS while (*--string == 'X')#else /* _MBCS */ while ((string>temp) && (!__isdbcscode(temp,string-1)) && (*--string == 'X'))#endif /* _MBCS */ { xcount++; *string = (char)((number % 10) + '0'); number /= 10; } if (*++string == '\0' || xcount != 6 ) return(NULL); olderrno = errno; /* save current errno */ set_errno(0); /* make sure errno isn't EACCESS */ while ((_access(temp,0) == 0) || (errno == EACCES)) /* while file exists */ { set_errno(0); if (letter == 'z'+1) { set_errno(olderrno); return(NULL); } *string = (char)letter++; } set_errno(olderrno); return(temp);}LONG RegOpenKeyEx( HKEY hKey, const char* lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult ){ USES_CONVERSION; return RegOpenKeyEx( hKey, A2T(lpSubKey), ulOptions, samDesired, phkResult ); }LONG RegCreateKeyEx( HKEY hKey, const char* lpSub, DWORD dwr, LPSTR lpcls, DWORD dwo, REGSAM sam, LPSECURITY_ATTRIBUTES lpsa, PHKEY phk, LPDWORD lpdw ){ USES_CONVERSION; return RegCreateKeyEx( hKey, A2T(lpSub), dwr, A2T(lpcls), dwo, sam, lpsa, phk, lpdw ); }LONG RegEnumKey(HKEY hKey, DWORD dwIndex, LPTSTR ptcsName, DWORD cbName){ DWORD cb = cbName; return RegEnumKeyEx( hKey, dwIndex, ptcsName, &cb, 0L, NULL, NULL, NULL ); }LONG RegDeleteKey( HKEY hKey, const char* lpSubKey ){ USES_CONVERSION; return RegDeleteKey( hKey, A2T(lpSubKey) ); }LONG RegEnumValueCe( HKEY hKey, DWORD dwIndex, LPTSTR ptcsValueName, LPDWORD lpcbValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData ){ return RegEnumValue( hKey, dwIndex, ptcsValueName, lpcbValueName, lpReserved, lpType, lpData, lpcbData );}LONG RegQueryValueEx( HKEY hKey, char* lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData ){ USES_CONVERSION; return RegQueryValueEx( hKey, A2T(lpValueName), lpReserved, lpType, lpData, lpcbData );}LONG RegSetValueEx( HKEY hKey, const char* lpValueName, DWORD Reserved, DWORD dwType, const BYTE *lpData, DWORD cbData ) { USES_CONVERSION; return RegSetValueEx( hKey, A2T(lpValueName), Reserved, dwType, lpData, cbData ); }LONG RegDeleteValue( HKEY hKey, const char* lpValueName ){ USES_CONVERSION; return RegDeleteValue( hKey, A2T(lpValueName) ); }UINT GetWindowsDirectory( char* lpBuffer, UINT uSize ){ strncpy(lpBuffer, "\\Windows", uSize ); return uSize; }DWORD GetPrivateProfileString( const char* lpAppName, // points to section name const char* lpKeyName, // points to key name const char* lpDefault, // points to default string char* lpReturnedString, // points to destination buffer DWORD nSize, // size of destination buffer const char* ) // points to initialization filename{ return -1L;}BOOL WritePrivateProfileString( const char* lpAppName, // pointer to section name const char* lpKeyName, // pointer to key name const char* lpString, // pointer to string to add const char* ) // pointer to initialization filename{ return FALSE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -