首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

linux c 有没有哪个查寻字符串的函数

2013-10-12 
linux c 有没有哪个查找字符串的函数linux c 有没有哪个查找字符串的函数不管查找或者没有查找到都不会改

linux c 有没有哪个查找字符串的函数
linux c 有没有哪个查找字符串的函数不管查找或者没有查找到都不会改动原始指针的?
[解决办法]
strstr函数算不算:
函数描述:
包含文件:string.h
函数名: strstr
函数原型:extern char *strstr(char *str1, char *str2);
功能:从字符串str1中查找是否有字符串str2,如果有,从str1中的str2位置起,返回str1中str2起始位置的指针,如果没有,返回null。
返回值:返回该位置的指针,如找不到,返回空指针。

[解决办法]
http://blog.csdn.net/max_min_go/article/details/9292101
参考下博客里的strstr函数
如果想不改变地址的话,自己额外保存一份就好了!
[解决办法]

STRSTR
Section: Linux Programmer's Manual (3 )
Updated: 2005-04-05 
--------------------------------------------
  
NAME
strstr - locate a substring   
SYNOPSIS
#include <string.h>

char *strstr(const char *haystack, const char *needle);

#define _GNU_SOURCE

#include <string.h>

char *strcasestr(const char *haystack, const char *needle);

  
DESCRIPTION
The strstr() function finds the first occurrence of the substring needle in the string haystack. The terminating `\0' characters are not compared. 
The strcasestr() function is like strstr(), but ignores the case of both arguments.   

RETURN VALUE
These functions return a pointer to the beginning of the substring, or NULL if the substring is not found.   
BUGS
Early versions of Linux libc (like 4.5.26) would not allow an empty needle argument for strstr(). Later versions (like 4.6.27) work correctly, and return haystack when needle is empty.   
CONFORMING TO
The strstr() function conforms to ISO 9899. The strcasestr() function is a non-standard extension.   
SEE ALSO
index(3), memchr(3), rindex(3), strchr(3), strcasecmp(3), strpbrk(3), strsep(3), strspn(3), strtok(3) 
--------------------------------------------

[解决办法]
++

引用:
strstr函数算不算:
函数描述:
包含文件:string.h
函数名: strstr
函数原型:extern char *strstr(char *str1, char *str2);
功能:从字符串str1中查找是否有字符串str2,如果有,从str1中的str2位置起,返回str1中str2起始位置的指针,如果没有,返回null。
返回值:返回该位置的指针,如找不到,返回空指针。

[解决办法]
http://man.chinaunix.net/develop/c&c++/linux_c/default.htm
参考一下,常用的linux c函数。
[解决办法]
google 很有效

热点排行