Skip to content

Instantly share code, notes, and snippets.

@evandertino
Last active August 29, 2015 14:05
Show Gist options
  • Save evandertino/71dc0ea4a33a72f2d97d to your computer and use it in GitHub Desktop.
Save evandertino/71dc0ea4a33a72f2d97d to your computer and use it in GitHub Desktop.
Back to C
#include <stdio.h>
void print(void);
unsigned long getId(void);
unsigned char getAge(void);
struct Student {
unsigned char Age;
unsigned long Student_ID;
void (*print)();
unsigned long (*getId)();
unsigned char (*getAge)();
}evander={4, 30, &print, &getId, &getAge};
void print(){
printf("Age of evander=%d and ID of evander=%d",(unsigned int)evander.Age, (unsigned int)evander.Student_ID);
}
unsigned long getId() {
return evander.Student_ID;
}
unsigned char getAge() {
return evander.Age;
}
int main(int argc, char ** argv) {
evander.print();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment