Mega Code Archive

 
Categories / C / Code Snippets
 

Allocate memory for struct

#include <stdlib.h> #include <stdio.h> #include <string.h> struct address { char name[450]; char street[450]; char city[450]; char state[40]; char zip[100]; }; int main() { struct address *j; if((j = malloc(sizeof(struct address)))==NULL) { printf("Allocation Error\n"); exit(1); } return j; }