Monday, May 24, 2010

How do you declare an array in a structure in C?

Is this right?





typedef struct listStruct


{


char word[20];


int counter;





pointer ptr;


} list;

How do you declare an array in a structure in C?
That works. If you don't know how large the array will be, you could also use "char*" (a pointer), and then later use malloc() to get memory for the array (as in "word = (char*)malloc(NumOfCharacters*sizeof(cha... As you have it written, you just need to make sure never to try to put 21 characters in the array. :)
Reply:yes its right 10/10

magnolia

No comments:

Post a Comment