Skip to content

Instantly share code, notes, and snippets.

View eraserhd's full-sized avatar

Jason Felice eraserhd

View GitHub Profile
@eraserhd
eraserhd / gist:94807e7bba504bd34759
Created August 24, 2014 17:57
A simple compiler
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *f;
char op;
int a, b;
scanf("%c %d %d", &op, &a, &b);
@eraserhd
eraserhd / compiler.c
Created August 24, 2014 17:58
A simple compiler
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *f;
char op;
int a, b;
scanf("%c %d %d", &op, &a, &b);
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int a_bunch_of_ints[100];
int kind_of_like_a_pointer;
a_bunch_of_ints[2] = 76;
a_bunch_of_ints[9] = 42;
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int a_bunch_of_ints[100];
int *pointer_a;
int *pointer_b;
pointer_a = &a_bunch_of_ints[2];
@eraserhd
eraserhd / foo.c
Last active August 29, 2015 14:05
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int a = 42;
printf("a is %d\n", a);
printf("The address of a is %p\n", &a);
exit(0);
}
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int a = 42;
int *b = &a; /* b contains the address of a. */
int **c = &b; /* c contains the address of b. */
printf("a is %d\n", **c); /* prints 42 -- *c would print b, **c prints a. */
exit(0);
@eraserhd
eraserhd / curses.cpp
Created September 8, 2014 19:34
Some curses stuff
#include <curses.h>
#include <iostream>
#include <string>
std::string myfunc()
{
std::string result = "Hello, World!";
return result;
}
@eraserhd
eraserhd / foo.cpp
Created September 16, 2014 17:01
Iterating through a map.
#include <map>
#include <iostream>
#include <string>
using namespace std;
int main() {
// A map
map<string, int> a_map;
// Put some things in it.
#include <algorithm>
#include <iostream>
using namespace std;
class Slime {
public:
int n;
// Constructor is a method with the same name as the class and
// no return type (it doesn't return anything).
@eraserhd
eraserhd / .vimrc
Created September 30, 2014 22:08
Current vim RC
" vi:set sts=2 sw=2 ai:
let &runtimepath = pathogen#surround(expand("<sfile>:p:h") . "/.homesick/repos/eraserhd/vimfiles") . "," . &runtimepath
call pathogen#infect()
filetype plugin indent on
set number
set nocompatible bs=2 ai viminfo='20,\"50 modelines=2
set foldmethod=marker nobackup writebackup
set switchbuf=usetab