Last active
February 27, 2016 18:12
-
-
Save madratman/ad83822c6fc40078b6eb to your computer and use it in GitHub Desktop.
compare_str_char_ptr.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <cstring> | |
#define xstr(a) str(a) | |
#define str(a) #a | |
int main() | |
{ | |
char* name = "madratman"; | |
if( xstr(name) == "name" ) | |
{ | |
std::cout << "1"; | |
} | |
if(!strcmp(xstr(name), "name")) | |
{ | |
std::cout << "1"; | |
} | |
if("madratman"==name) | |
{ | |
std::cout << "1"; | |
} | |
if ("madratman"=="madratman") | |
{ | |
std::cout << "1"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment