我想请教C语言中在一个source字符串中查找指定子字符串target的函数是什么

jhtisboy 2003-04-25 02:51:36
我本来这几天正在问有没有c的函数库,问了半天
没有看到好的书,只有先问问这个了
...全文
378 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jhtisboy 2003-04-25
  • 打赏
  • 举报
回复
楼上的,你能不能解释一下strtok的含意呢
jhtisboy 2003-04-25
  • 打赏
  • 举报
回复
没有人知道了吗
fangrk 2003-04-25
  • 打赏
  • 举报
回复
#include <string.h>
#include <stdio.h>

int main(void)
{
char input[16] = "abc,d";
char *p;

/* strtok places a NULL terminator
in front of the token, if found */
p = strtok(input, ",");
if (p) printf("%s\n", p);

/* A second call to strtok using a NULL
as the first parameter returns a pointer
to the character following the token */
p = strtok(NULL, ",");
if (p) printf("%s\n", p);
return 0;
}
jhtisboy 2003-04-25
  • 打赏
  • 举报
回复
另外有没有根据某个分隔符分隔出字符串数组来的函数?
jhtisboy 2003-04-25
  • 打赏
  • 举报
回复
有没有给出字符串的起始位置的?
fangrk 2003-04-25
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <string.h>

int main(void)
{
char *str1 = "Borland International", *str2 = "nation", *ptr;

ptr = strstr(str1, str2);
printf("The substring is: %s\n", ptr);
return 0;
}

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧