Thread: Question About Dynamic Arrays Using ReAlloc()
i hoping me understanding realloc() function can dynamically change size of array program progresses...
code:#include <stdlib.h> int main(int argc, char *argv[]){ int i=0; struct timeval *my_array; int my_array_len=0; my_array = (struct timeval *)malloc (sizeof(struct timeval) ); for(i=0; < 999999999999999; i++){ int randvar = rand(); if(randvar > 100){ //increase size of array <missing> struct timeval timev; gettimeofday( &timev, null ); my_array[my_array_len++] = timev; printf("%i\n", my_array_len); } } return 0; }
did read man page? part don't understand?
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] Question About Dynamic Arrays Using ReAlloc()
Ubuntu
Comments
Post a Comment