C. J. Clegg said:
Consider this code:#ifndef BETTER_CLASS_GRADE
char* s;
char* putSomethingThere( void );
s = putSomethingThere( );
if( s == "abc" )
{
...
}
If I remember correctly, that's correct C++ but incorrect C, even if
putSomethingThere() put "abc" into s, right?
#include <stdio.h>
#include <string.h>
int
main(void)
{
char *s = "abc";
if(!strcmp(s, "abc"))
puts("equal!");
return 0;
}
#else
#include <iostream>
#include <string>
using namespace std;
int
main(void)
{
string s("abc");
if(s == "abc")
cout << "equal!" << endl;
return 0;
}
#endif
You're welcome.
Yours,
Han from China