#include<stdio.h>#include<string.h>#define M 30void input(char *p[]){ int i=0; printf("输入一串单词:"); while((scanf("%s",p[i]))!='\0') { i++; }; p[i+1]=NULL;}int handle(char *p[]){ int i=0; char *p1=NULL; printf("\n需要查找的单词:"); scanf("%s",p1); while(strcmp(*p[i],*p1)!=0) //错了 { i++; if(p[i]==NULL) return -1; } return i;}void output(char *p[],int m){ if(m==-1) printf("没有需要查找的字符!\n"); else printf("需要查找的单词出现在第%d个\n");}void main(){ int m; char *p[M]=NULL;//错了 input(p); m=handle(p); output(p,m);}
错误提示是:D:\安装程序\VC6CN\MSDev98\Bin\qw.cpp(23) : error C2664: 'strcmp' : cannot convert parameter 1 from 'char' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast D:\安装程序\VC6CN\MSDev98\Bin\qw.cpp(23) : fatal error C1903: unable to recover from previous error(s); stopping compilation 执行 cl.exe 时出错.