Skip to content

Instantly share code, notes, and snippets.

@ywatase
Created April 26, 2012 07:03
Show Gist options
  • Save ywatase/2496997 to your computer and use it in GitHub Desktop.
Save ywatase/2496997 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <time.h>
enum {
MAX = 10,
};
typedef struct Nameval Nameval;
struct Nameval {
char *name;
int value;
};
void main(){
Nameval htmlchars[] = {
"AEIig" , 0x00c6,
"Aacute" , 0x00c1,
"Acirc" , 0x00c2,
"zeta" , 0x03b6,
};
Nameval *p1, *p2;
printf("sizeof int: %d\n",sizeof(int));
printf("sizeof long: %d\n",sizeof(long));
printf("sizeof char*: %d\n",sizeof(char*));
printf("sizeof Nameval: %d\n",sizeof(Nameval));
printf("%p\n", p1 = &htmlchars[0]); //
printf("%p\n", p2 = &htmlchars[2]);
printf("%d\n", p2 - p1);
printf("%d\n", (void*)p2 - (void*)p1);
printf("%d\n", (long*)p2 - (long*)p1);
}
int is_odd_number(int n) {
printf("%f: %f \n", (float) n, (float) (n % 2));
}
#define NELEMS(array) (sizeof(array) / sizeof(array[0]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment