www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/07/21:30:36

From: XXguille AT XXiies DOT XXes (Guillermo Rodriguez Garcia)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Using pointers
Date: Fri, 07 May 1999 17:02:07 GMT
Organization: Telefonica Transmision de Datos
Lines: 32
Message-ID: <37351c58.2056117@noticias.iies.es>
References: <Pine DOT BSF DOT 3 DOT 96 DOT 990507090735 DOT 15546B-100000 AT studenti DOT ing DOT unipi DOT it> <7gu5bt$u5e$1 AT hagen DOT cloud9 DOT co DOT uk>
NNTP-Posting-Host: iies141.iies.es
Mime-Version: 1.0
X-Newsreader: Forte Agent 1.5/32.451
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019