Mail Archives: djgpp/1999/05/07/21:30:36
El día Fri, 7 May 1999 08:42:47 +0100, "Michael Stewart"
<mike AT reggin DOT freeserve DOT co DOT uk> escribió:
>GiovanniB wrote in message ...
>>
>> When I declare a pointer (i.e. int* myptr) it's possible to use it in
>>this way :
>> for(int i = 0; i < n; i++)
>> {
>> myptr[i] = somenumber;
>> }
>>where n is a number big than biggest int ?
^^^^^^^^
I think you're missing the point here!
>You can indeed treat a pointer as an array, in a sense thats what it is.
>Just remember to allocate the memory.
>
>/* C */
>myptr = (int *) malloc (n * sizeof (int));
>
>/* C++, I think this is how to do it */
>myptr = new (int)[n];
>
>Michael Stewart
Regards,
GUILLE
----
Guillermo Rodriguez Garcia
XXguille AT XXiies DOT XXes (ya sabes :-)
- Raw text -