Can someone explain how pointer to pointer works?

Posted by user3549560 on Stack Overflow See other posts from Stack Overflow or by user3549560
Published on 2014-05-30T20:52:46Z Indexed on 2014/05/30 21:26 UTC
Read the original article Hit count: 210

Filed under:
|
|
|

I don't really understand how the pointer to pointer works. Any way to do the same work without using pointer to pointer?

    struct customer{
        char name[20];
        char surname[20];
        int code;
        float money;
    };
    typedef struct customer customer;
    void inserts(customer **tmp) 
    {
    *tmp = (customer*)malloc(sizeof(customer));
    puts("Give me a customer name, surname code and money");
    scanf("%s %s %d %f", (*tmp)->name, (*tmp)->surname, &(*tmp)->code,&(*tmp)->money);
    }

© Stack Overflow or respective owner

Related posts about c

    Related posts about pointers