Search Results

Search found 1 results on 1 pages for 'user1763861'.

Page 1/1 | 1 

  • Structs and pointers

    - by user1763861
    I have a few questions about structs and pointers For this struct: typedef struct tNode_t { char *w; } tNode; How come if I want to change/know the value of *w I need to use t.w = "asdfsd" instead of t->w = "asdfasd"? And I compiled this successfully without having t.w = (char *) malloc(28*sizeof(char)); in my testing code, is there a reason why tt's not needed? Sample main: int main() { tNode t; char w[] = "abcd"; //t.word = (char *) malloc(28*sizeof(char)); t.word = w; printf("%s", t.word); } Thanks.

    Read the article

1