Skip to content

Instantly share code, notes, and snippets.

@madratman
Last active February 27, 2016 18:12
Show Gist options
  • Save madratman/ad83822c6fc40078b6eb to your computer and use it in GitHub Desktop.
Save madratman/ad83822c6fc40078b6eb to your computer and use it in GitHub Desktop.
compare_str_char_ptr.cpp
#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