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: <7gu5bt$u5e$1 AT hagen DOT cloud9 DOT co DOT uk> NNTP-Posting-Host: iies141.iies.es Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit 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" 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 :-)