Lets say I have the following code:
Now I have the following:Code:struct node { int length; int *msg; struct node* next; };
I'm having trouble printing out the contents of the integer array msg. It seems to only print the first character/integer. I sprinkled a printf() to see what my value of length was and it was correct but for some reason I can't seem to get msg to print, using arrays, using pointers and using fwrite() to stdout. I'm not entirely sure if my fread() arguments are correct but I thought it could be due to msg being a pointer and sizeof() that would only be one. But I tried sizeof(*(new->msg)) to no avail.Code:// Some code here fp = fopen(argv[i],"rb"); struct node* new = malloc(sizeof(struct node)); new->msg = malloc(sizeof(int)*(new->length)); // say you already got a length items_read = fread(new->msg, sizeof(new->msg),1,fp);
Any ideas?![]()



LinkBack URL
About LinkBacks




I used to be an adventurer like you... then I took an arrow to the knee.