4_30.cpp
上传用户:zipjojo
上传日期:2009-07-20
资源大小:70k
文件大小:1k
源码类别:

文章/文档

开发平台:

C/C++

  1. # include<iostream.h>
  2. # include<string.h>
  3. void search(char*list[],char obj[],int len)
  4. {
  5. char** p;
  6. p=list;
  7. while(p<list+len)
  8. {
  9. if(strcmp(*p,obj)==0)
  10. break;
  11. else p++;
  12. }
  13. if(p<list+len)
  14. cout<<"Success! The sequential number="<<p-list+1<<endl;
  15. else 
  16. cout<<"Unsucess!"<<endl;
  17. }
  18. void main()
  19. {
  20. char*a[10]={"aa","bbb","cccc","ddddd","eeeeee","fffffff"};
  21. for (int i=0;i<6;i++)
  22. cout<<*(a+i)<<" ";
  23. char c[20];
  24. cout<<endl;
  25. cout<<"请输入要查阅的字符串:";
  26. cin>>c;
  27.     char *b;
  28.     b=c;
  29.     void (*s)(char*[],char*,int);
  30.     s=search;
  31.     (*s)(a,c,6);
  32. }