Hi,
I know now that you can't define an array with the size determined at runtime. I'm trying to think of a useful work around that I could incoperate into a header file.
I'd like to create a header file that does a lot of the leg work of working around the problem of variable size arrays ( stop me if this isn't possible, I'm new ).
int i;
int *ptr = (int*) calloc ( 100, sizeof (int));
if (ptr == NULL)
printf("Calloc failed!");
for (i=0;((getchar () != 'x') == 1);i++) {
ptr[i] = getchar ();
}
At this point in any program I could have put into this block of memory ( ptr ) upto 100 integers. Firstly any ideas on how to shrink this into memory space into only the size I need it ( say I put in 5 numbers then have the array only holding 5 numbers and not 95 other "0"s as well).
From that could I produce a header file which could make this into a command I call as if you can enter variable size arrays.
I don't think I got my point arross well there, sorry about that. I'm not looking for code here. Just a shove in the right direction if its possible and to be told if its not.
Thanks