永发信息网

C语言中是否有类似VB 中Instr()函数

答案:3  悬赏:0  手机版
解决时间 2021-02-28 04:40
  • 提问者网友:抽煙菂渘情少年
  • 2021-02-27 13:17
Instr(n,s1,s2)返回在s1字符串中,从第n个字符开始,寻找s2字符,找到返回位置,找不到返回0(s2也可以是字符串(即字符数组);如果s2长度大于s1,也返回0)
如果没有,哪个仁兄帮忙编个这样的函数。。。
如Instr(2,"abcd","c")=3
Instr(2,"abcd","cd")=3
...
最佳答案
  • 五星知识达人网友:酒醒三更
  • 2021-02-27 13:38
当然有:
#include
char *strstr(const char *haystack, const char *needle);

Return
It returns a pointer into the string haystack that is the first character of
the substring, or a null pointer if no match was found. If needle is an empty
string, the function returns haystack.

Description
This is like strchr() , except that it searches haystack for a substring
needle rather than just a single character.

顺便,如果你自己写不出这样的函数,不建议你继续学习C。
全部回答
  • 1楼网友:玩世
  • 2021-02-27 15:14
没有,有这个函数 char *strchr(cs, c) return pointer to first occurrence of c in cs or NULL if not present
  • 2楼网友:佘樂
  • 2021-02-27 14:20
你好! 没有,有这个函数 char *strchr(cs, c) return pointer to first occurrence of c in cs or NULL if not present 希望对你有所帮助,望采纳。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯