DESCRIPTION
The strstr() function finds the first occurrence of the substring nee-
dle in the string haystack.
RETURN VALUE
The strstr() function returns a pointer to the beginning of the sub-
string, or NULL if the substring is not found.
SYNOPSIS
#include <string.h>
char *strtok(char *s, const char *delim);
DESCRIPTION
The strtok() function can be used to parse the string s into tokens.
The first call to strtok() should have s as its first argument. Subse-
quent calls should have the first argument set to NULL. Each call
returns a pointer to the next token, or NULL when no more tokens are
found.
If a token ends with a delimiter, this delimiting character is over-
written with a \0 and a pointer to the next character is saved for the
next call to strtok(). The delimiter string delim may be different for
each call.
The strtok_r() function is a reentrant version of the strtok() func-
tion, which instead of using its own static buffer, requires a pointer
to a user allocated char*. This pointer, the ptrptr parameter, must be
the same while parsing the same string.
或者楼主到baidu google 随便一搜作者: soul_of_moon 时间: 2006-04-27 16:20
原帖由 mike_chen 于 2006-4-27 15:35 发表
这两天全是这个问题,你们是不是都是老师给统一安排的作业呀!
strstr
or
strtok
应该是strchr吧作者: stiandao 时间: 2006-04-27 16:24
int split(char sp, char *line, char **lst, int lst_len)
{
int i;
lst[0] = line;
for (i=1; *line; line++)
{
if (*line == sp)
{
*line = '\0';
if (i >= lst_len) break;
lst[i++] = line + 1;
}
}
return i;
}
char *pList[80];
split('|',src,pList,80);作者: 流川 时间: 2006-04-27 23:45
is sample
write a program and no libary作者: atg 时间: 2006-04-28 12:56
自己写吧很容易的作者: gamegod 时间: 2006-04-29 12:37
用boost中的tokenizer可以解决这个问题
template <
class TokenizerFunc = char_delimiters_separator<char>,
class Iterator = std::string::const_iterator,
class Type = std::string
>
class tokenizer作者: 2eye 时间: 2006-04-29 12:51
string str;
vector<string> v;
while( cin.get(ch) ){
if( ch != '|' ) str.push_back(ch);
else{
v.push_back(str);
str = "";
}
}作者: apexg 时间: 2006-05-02 12:01 标题: 可以解决字段内容中存在"|"的情况么 一种情况是:12|asb|张弢fds|33543.33|
弢字的后半部分是竖线
另外一种情况是:12|asb|张?fds|33543.33|,即字段内容中有半个汉字或者乱码的情况.
各位高手,如何准确的拆分?使用标准c