Skip to content

Instantly share code, notes, and snippets.

@gon1332
Last active August 29, 2015 14:04
Show Gist options
  • Save gon1332/49ee86360c373876df85 to your computer and use it in GitHub Desktop.
Save gon1332/49ee86360c373876df85 to your computer and use it in GitHub Desktop.
Compare strings in C in a more physical way
#include <stdio.h>
#include <string.h>
#define STRCMP(a, R, b) (strcmp(a,b) R 0)
int main(void)
{
char *s = "John";
if (STRCMP("john", ==, s))
fputs("The same", stdout);
else
fputs("Not the same", stdout);
fprintf(stdout, "\n%d", STRCMP("Abc", >, "abc"));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment