在一些字符串中找特定字符

来源:互联网 发布:ubuntu安装搜狗拼音 编辑:程序博客网 时间:2024/05/16 10:19
#include <stdio.h>      int find_char( char **strings, char value)  {          while( *strings != NULL)      {          while( **strings != '\0')          {              if( value == *(*strings)++ )  {  return 1;}        }          strings++;    }      return 0;}    int main()  {      char *str[10] = {"hello", "world", "abcd",NULL};         char ch = 'f';         if( find_char(str, ch) == 1 )      {          printf("%c was found!\n", ch);      }      else      {          printf("%c was not found!\n", ch);      }   return 0;    }  

0 0
原创粉丝点击