PREV INDEX NEXT

Author: Unknown
Subject: Trouble with createD in Deque.c
Date: Tuesday, 17 Mar 2020, 09:35:32

Hello Professor Eisenstat,

I am having two issues with the code in Deque.c so far. The first is a compilation error that I know how to fix but don't understand why I need to fix it. I am setting d, the argument input to createD, equal to a malloc statement. Therefore d should be a pointer to a malloced block (for a struct). Then I am trying to use the arrow notation, d->, to set the malloced block's values. However, setting d-> equal to something gives me the error: error: `*d' is a pointer; did you mean to use `->'?. My problem is solved when I use (*d)-> instead. If d is pointing to the block already, why do I need to dereference d twice? 

Another issue I am having that isn't causing problems in my code yet but I fear may later is the fact that the declarations of the structs are confined to the brackets I declared them in. I am declaring two structs, a deque struct and an elt struct. I would want the deque struct to include pointers to pointers to elts, but compilation errors tell me elt is unknown when I try to do that in the deque. For now, I have my deque struct written as pointers to pointers to chars instead, but they are actually pointing to pointers to elts so I am confused as to how to change this. 

Thanks so much!
PREV INDEX NEXT