场景:
1. 标准库里的 ctype.h里的函数是用于1个字节的判断的,但是参数却是int, 这样很容易导致误用....
分类:
编程语言 时间:
2015-09-29 16:58:22
阅读次数:
223
tokenizer 库提供预定义好的四个分词对象,其中char_delimiters_separator已弃用. 其他如下:1. char_separator char_separator有两个构造函数1 char_separator() 使用函数 std::isspace() 来识别被弃分...
分类:
其他好文 时间:
2015-09-10 12:33:38
阅读次数:
208
int isspace( char c ){ char comp[] = { ' ', '\t', '\r', '\n', '\v', '\f' }; const int len = 6; for ( int i=0; i= 'A' && c = s ); return NULL;}// 在字符.....
分类:
其他好文 时间:
2015-09-03 17:56:07
阅读次数:
147
// 模拟实现库函数的atof函数
#include
#include
#include
#include
double my_atof(char const *p)
{
double ret = 0;
int flag = 1;
int count = 0;
assert(p != NULL);
while (isspace(*p))
{
p++;
}
whil...
分类:
编程语言 时间:
2015-07-04 16:47:04
阅读次数:
138
// 模拟实现库函数的atoi函数
#include
#include
#include
#include
int my_atoi(char const *p)
{
int ret = 0;
int a = 0;
int flag = 1;
assert(p != NULL);
while (isspace(*p))
{
p++;
}
while (*p)
{
...
分类:
编程语言 时间:
2015-07-04 15:31:00
阅读次数:
170
void EraseMultiSpace(std::string &str)
{
bool alnumFlag = false;
bool spaceFlag = false;
int j=0;
int j=0;
for (int i=0; i
{
if(!isspace(str.at(i)))
{
str.at(j) = str.at(i);
j++;
alnu...
分类:
其他好文 时间:
2015-06-26 18:11:37
阅读次数:
128
#include #include #include #include //删除右边连续的空格,char* rtrim(char *pstr){ char *p = pstr; int len = strlen(pstr); p += len - 1; for(; ...
分类:
其他好文 时间:
2015-06-18 08:12:59
阅读次数:
97
转载:http://www.ggv.com.cn/forum/clib/ctype/isspace.html函数isspace原型:extern int isspace(int c); 用法:#include 功能:判断字符c是否为空白符 说明:当c为空白符时,返回非零值,否则返回零。 空白...
分类:
编程语言 时间:
2015-06-13 11:06:33
阅读次数:
125
判断字符串
s.isalnum() #所有字符都是数字或者字母
s.isalpha() #所有字符都是字母
s.isdigit() #所有字符都是数字
s.islower() #所有字符都是小写
s.isupper() #所有字符都是大写
s.istitle() #所有单词都是首字母大写,像标题
s.isspace() #所有字符都是空白字符、\t、\n
大小写转换
s....
分类:
其他好文 时间:
2015-05-14 12:07:26
阅读次数:
103
1 #include 2 #include 3 using namespace std; 4 5 6 int main() 7 { 8 string str("some thing"); 9 for(auto &c:str)10 if(!isspace(c)...
分类:
其他好文 时间:
2015-04-16 12:19:40
阅读次数:
91