1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #include <iostream> #include <string> //Main should return 0 on success. int main() { //Use the standard namespace so there's no need to prefix cout with std:: using namespace std; char a[99]; cout << "Please enter your name here:" << endl; cin >> a; // Use strcmp to compare strings, not ==. if ( strcmp(a, "reet") == 0) { cout << "yes"; } else { cout << "no"; } //Print a new line. cout << endl; return 0; } |
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgoKCi8vTWFpbiBzaG91bGQgcmV0dXJuIDAgb24gc3VjY2Vzcy4KaW50IG1haW4oKSB7CgoJLy9Vc2UgdGhlIHN0YW5kYXJkIG5hbWVzcGFjZSBzbyB0aGVyZSdzIG5vIG5lZWQgdG8gcHJlZml4IGNvdXQgd2l0aCBzdGQ6OgoJdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCgljaGFyIGFbOTldOwoKCWNvdXQgPDwgIlBsZWFzZSBlbnRlciB5b3VyIG5hbWUgaGVyZToiIDw8IGVuZGw7CgljaW4gPj4gYTsKCgkvLyBVc2Ugc3RyY21wIHRvIGNvbXBhcmUgc3RyaW5ncywgbm90ID09LgoJaWYgKCBzdHJjbXAoYSwgInJlZXQiKSA9PSAwKSB7CgkJY291dCA8PCAieWVzIjsKCX0gZWxzZSB7CgkJY291dCA8PCAibm8iOwoJfQoKCgkvL1ByaW50IGEgbmV3IGxpbmUuCgljb3V0IDw8IGVuZGw7CgoJcmV0dXJuIDA7Cn0K
prog.cpp: In function ‘int main()’: prog.cpp:17: error: ‘strcmp’ was not declared in this scope
-
result: Compilation error (maybe you wish to see an example for C++ 4.7.2)


