读书人

求指定字符在字符串中得位置解决方案

发布时间: 2012-03-26 15:46:55 作者: rapoo

求指定字符在字符串中得位置
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char *s1="DBACEGF",*S2="ABCDEFG";
int n=strchr(s2,s1[0])-s2;
cout<<n<<endl;
system("pause")return 0;
}

编译时为什么出错??怎么样改??

[解决办法]

C/C++ code
#include<iostream>#include<string.h>using namespace std;int main(){  char *s1="DBACEGF",*s2="ABCDEFG";  int n=strchr(s2,s1[0])-s2;  cout<<n<<endl;  system("pause");  return 0;} 

读书人网 >C语言

热点推荐