Skip to main content

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

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support