Computer
Systems

Spring 2013
course
navigation

questions

Anyone in the class can edit this page.
Brownie points for both good questions and good answers.

your question

Ask away.
When you define triple here typedef struct _triple *triple; struct _triple { int a; int b; int c; }; Why can you drop the underline at the beginning? (like here) triple new_triple(int a, int b, int c){ // Allocate memory on the heap for this thing, and return a pointer to it. triple t = (triple) malloc(sizeof(struct _triple)); t->a = a; . . . and here int sum = 1000; triple p; printf("Looking...") Okay, never mind. I found my answer here.
  • the * is lets the compiler know that the name is a pointer and not not part of the name of the typedef
  • typedef struct _triple {} *triple allows for a quick way to declare a variable of struct _triple type by just stating triple p;
  • _triple is the name of that struct definition
  • sizeof(struct _triple) gets the size of the struct defined as _triple
Alternate way mentioned by Alex Hiam typedef struct _triple { int a; int b; int c; } *triple;
http://cs.marlboro.edu/ courses/ spring2013/systems/ wiki/ questions
last modified Wednesday January 30 2013 4:55 pm EST