malloc: allocate memory : malloc « stdlib.h « C / ANSI-C

malloc: allocate memory


//Declaration: void *malloc(size_t size); 
//Return:      returns a pointer to the memory. 
               If there is insufficient memory, malloc() returns a null pointer. 



  struct addr {
    char name[40];
    char street[40];
    char zip[10];

    struct addr *p;

    p = malloc(sizeof(struct addr));

    if(p==NULL) {
      printf("Allocation Error\n");
    return p;


Related examples in the same category