gpt4 book ai didi

c - 使用 'srtchr()' 搜索子串

转载 作者:太空宇宙 更新时间:2023-11-04 05:34:02 25 4
gpt4 key购买 nike

使用函数 strchr 是否可以在字符串中搜索 substring 而不是 character

示例:

而不是这个:

int r=strchr("Hello World",'W');

这个可以用吗:

int r=strchr("Hello World","World");

最佳答案

Using the function 'strchr()' is it possible to search for a 'substring' in a string instead of a 'character'?

Example :

Instead of this : int r=strchr("Hello World",'W');

Can this be used : int r=strchr("Hello World","World");

不,那是strstr() is for .

另请注意 strchr()不返回 int,它返回指向所搜索字符的 char * 指针,如果未找到则返回 NULL。存在编译器警告是有原因的...

关于c - 使用 'srtchr()' 搜索子串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47773154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com