当前位置: 动力学知识库 > 问答 > 编程问答 >

Is there any function to search for string in string in C?

问题描述:

Is there any function in C which searches for a string in a string and returns 0 or 1.

Let's say string 1 is "I love the whole world" and I want to search for "love" then is there any function which appropriately returns 0 if not found and returns 1 if found.

网友答案:

strchr() searches for a character within a given string.

However, you want to find love in I love the whole world, so you're searching a string in another. Take strstr() for this.

While both functions don't return 0 or 1, I trust you to be able to wrap them in a way so that they do.

分享给朋友:
您可能感兴趣的文章:
随机阅读: