The errors I get are:
error C2040: 'a' : 'char *' differs in levels of indirection from 'char'
1>c:\users\jonathan\documents\visual studio 2010\projects\prog8-30\prog8-30\prog8-30.cpp(17): error C2040: 'b' : 'char *' differs in levels of indirection from 'char'
1>c:\users\jonathan\documents\visual studio 2010\projects\prog8-30\prog8-30\prog8-30.cpp(20): error C2088: '>>' : illegal for class
1>c:\users\jonathan\documents\visual studio 2010\projects\prog8-30\prog8-30\prog8-30.cpp(21): error C2088: '>>' : illegal for class
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
# include <iostream>
# include <cstdio>
# include <cstring>
usingnamespace std;
int main()
{
char firstStr[100],secondStr[100];
cout << "Please enter the first strings -> ";gets(firstStr);
cout << "Please enter the second strings -> ";gets(secondStr);
int i = strcmp(firstStr,secondStr);
if(i==0)
{
cout << "The two strings are equal" << endl;
}elseif(i>0)
{
cout << "The first string is greather than the second string" << endl;
}else cout << "The second string is greather than the first string" << endl;
return 0;
}
I prefer using string .In fact I only work with strings .It just when It comes for beginers I write code using the old c string style because they begin with them first
# include <iostream>
usingnamespace std;
int main()
{
string firstStr,secondStr;
cout << "Please enter the first strings -> ";getline(cin,firstStr);
cout << "Please enter the second strings -> ";getline(cin,secondStr);
int i = firstStr.compare(secondStr);
if(i==0)
{
cout << "The two strings are equal" << endl;
}elseif(i>0)
{
cout << "The first string is greather than the second string" << endl;
}else cout << "The second string is greather than the first string" << endl;
return 0;
}