查找字符串的子串 [英] Find sub-string in string

查看:142
本文介绍了查找字符串的子串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在存在C法在字符串找到一个子?

如果没有,如何有效地解决这个问题处理?

在对周期?什么是在C正确的语法?

 为const char子[] = {车,蓝,红};
字符的String [] =我喜欢红色,我讨厌蓝色;对于....串lenght ... {      的printf(我发现子);}


解决方案

有关空结尾的C字符串:

的strstr()

Exists in C method for finding a substring in a string?

If not, how to effectively deal with this problem?

In for cycle? And what is the correct syntax in c?

const char subString[] = { "car", "blue", "red"};
char String[] = "I love red color and i hate blue color";

for .... String lenght... {

      printf("I found subString");

}

解决方案

For null terminated C strings:

strstr()

这篇关于查找字符串的子串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆