/*
逐个读取字符串中的字符,当所给字符与字符串中的字符相同时,计数器count的值加1后继续查找,直到字符串尾。
一个完整的参考程序如下:
*/
#include <iostream>
//#include <conio.h>
void main()
{
using namespace std;
int count =0;
int j;
char str[100],c[100];
cout<<"input a string:";
cin>>str;
//cout <<sizeof(str)/sizeof(char);
cout<< "input another string:";
for(int i = 0; i < *(str+i)!='\0'; ++i){
cin>>*(c+i);
}
*(c+i) = '\0';
//cout << c;
//cout<<"the count is:"<<char_compare(str,c)<<endl;
//if(sizeof(str)==sizeof(c)&&char_compare(str,c)==sizeof(str)/sizeof(char))cout << "win";
for(j = 0;*(str+j)!='\0'; ++j){
//cin>>*(c+i);
if(*(str+j)==*(c+j)) count+=1;
else continue;
}
if(count==j)cout << "win";
else cout << "oh no";
//getch();
}
/*
⑵上机要求
修改程序输出每个字符和其出现的次数,不允许字符重复输出。
⑶写出实验报告
1.3项目选做:
自定义函数实现库函数strcmp()和strlen()的功能。
*/