Skip to content

Instantly share code, notes, and snippets.

@daGrevis
Created May 15, 2012 12:19
Show Gist options
  • Select an option

  • Save daGrevis/2701327 to your computer and use it in GitHub Desktop.

Select an option

Save daGrevis/2701327 to your computer and use it in GitHub Desktop.
Char math
#include <stdio.h>
int main(int argc, char *argv[]) {
char foo = 'C';
char bar = 'A';
puts(foo - bar);
return 0;
}
@daGrevis

Copy link
Copy Markdown
Author
[dagrevis@raitis C]$ make hello_world
cc -Wall -g    hello_world.c   -o hello_world
hello_world.c: In function ‘main’:
hello_world.c:8:2: warning: passing argument 1 of ‘puts’ makes pointer from integer without a cast [enabled by default]
/usr/include/stdio.h:690:12: note: expected ‘const char *’ but argument is of type ‘int’
[dagrevis@raitis C]$ ./hello_world 
Segmentation fault (core dumped)

@daGrevis

Copy link
Copy Markdown
Author

printf("%d", foo - bar);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment