From: "Michael Stewart" Newsgroups: comp.os.msdos.djgpp Subject: Re: Using pointers Date: Fri, 7 May 1999 08:42:47 +0100 Organization: USENET UK Lines: 24 Message-ID: <7gu5bt$u5e$1@hagen.cloud9.co.uk> References: NNTP-Posting-Host: hgty.capgemini.co.uk X-Trace: hagen.cloud9.co.uk 926062781 30894 194.42.240.2 (7 May 1999 07:39:41 GMT) X-Complaints-To: abuse AT usenet DOT co DOT uk NNTP-Posting-Date: 7 May 1999 07:39:41 GMT X-Newsreader: Microsoft Outlook Express 4.72.3155.0 X-Mimeole: Produced By Microsoft MimeOLE V4.72.3155.0 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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 ? 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