📄 commonutility.h
字号:
#ifndef _COMMONUTILITY_
#define _COMMONUTILITY_
#include <ctime>
#include <string>
#include <iostream>
using namespace std;
#include "randomc.h"
static TRanrotWGenerator RG((long)time(NULL));
#ifndef _MAX_PATH
#define _MAX_PATH 260
#endif
#ifdef _WIN32
#define GETLINE(in,buffer) (in.getline(buffer, sizeof(buffer)))
#else
#define GETLINE(in,buffer) in.getline(buffer, 4096)
#endif
#ifndef _WIN32
inline int _stricmp(const char* a, const char* b)
{
if(a == NULL || b == NULL)
return -1;
char tokena[1024]={0}, tokenb[1024]={0};
strcpy(tokena, a);
strcpy(tokenb, b);
for(size_t i=0;i<strlen(a);i++)
if(tokena[i] >= 'A' && tokena[i] <= 'Z')
tokena[i] += 32;
for(size_t i=0;i<strlen(b);i++)
if(tokenb[i] >= 'A' && tokenb[i] <= 'Z')
tokenb[i] += 32;
return strcmp(tokena, tokenb);
}
inline void _splitpath(const char *path, char *drive, char *dir, char *fname, char *ext)
{
string tmppath, tmpdir, tmpname, tmpext;
tmppath.clear();
tmpdir.clear();
tmpname.clear();
tmpext.clear();
tmppath = path;
int dirlen = tmppath.find_last_of("\\/");
int namelen = tmppath.find_last_of(".");
int extlen = tmppath.length();
tmpdir = tmppath.substr(0, dirlen+1);
tmpname = tmppath.substr(dirlen+1, namelen-dirlen-1);
if(namelen == -1)
tmpext = "";
else
tmpext = tmppath.substr(namelen, extlen-namelen);
drive = NULL;
sprintf(dir,"%s", tmpdir.c_str());
sprintf(fname,"%s",tmpname.c_str());
sprintf(ext,"%s", tmpext.c_str());
}
inline int _isnan(double test)
{
return isnan(test);
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -