c - Malloc return 0? -
c - Malloc return 0? -
i'm doing homework project in c using dev-c++ compiler. strangely, i've stucked @ malloc function returns me 0 mean out of heap memory. hardly uncertainty memory full. i've included windows.h library.
this problematic part of function. printf gives me:
00000000 ... 00000000 .... 005c1058
what wrong here?
typedef struct tcat { char *namec; struct tcat *nextc; struct tprod *firstp; }ctgr; typedef struct tprod { char *namep; float price; int qt; struct tprod *nextp; }prdct; void srch(int i) { //data base of operations population int k,r; //categories of components ctgr *p,*primc; primc = (ctgr *)malloc(sizeof(ctgr)); primc -> namec = "resistances"; p = primc -> nextc; p -> namec = "capacitors"; p -> nextc = 0; prdct *q,*primrp,*primcp; primrp = (prdct *)malloc(sizeof(prdct)); primcp = (prdct *)malloc(sizeof(prdct)); printf(" %p ... %p .... %p",primrp,primcp,primc); getch(); p = primc -> nextc;
may culprit. value not set , anything, when assign through it, you're writing unpredictable place in memory.
c memory malloc heap dev-c++
Comments
Post a Comment