strstr函数

来源:互联网 发布:领导风格测试软件 编辑:程序博客网 时间:2024/05/17 05:05
函数名: strstr
  功 能: 在字符串中查找指定字符串的第一次出现
  用 法: char *strstr(char *str1, char *str2);
  用法:#include <string.h>
  功能:

       str1: 被查找目标 string expression to search.
  str2:要查找对象 The string expression to find.
  该函数返回str2第一次在str1中的位置的指针,如果没有找到,返回NULL
  #include <syslib.h>
  #include <string.h>
  main()
  {
  char *s="Golden Global View";
  char *l="lob";
  char *p;
  clrscr();
  p=strstr(s,l);
  if(p)
  printf("%s",p);
  else
  printf("Not Found!");
  getchar();
  return 0;
  }

输出:lobal View


  语法:* strstr(str1,str2)
  str1: 被查找目标 string expression to search.
  str2:要查找对象 The string expression to find.
  该函数返回str2第一次在str1中的位置,如果没有找到,返回NULL