From: "Steve Chalkley" Newsgroups: comp.os.msdos.djgpp Subject: Re: pointers Date: Sat, 11 Dec 1999 12:57:45 -0000 Organization: NTL Internet News Service Lines: 54 Message-ID: <82thn7$ef5$1@nclient9-gui.server.ntli.net> References: <384CD097 DOT B95E1019 AT dtn DOT ntl DOT com> NNTP-Posting-Host: p-75-belinda.tch.cableol.net X-Trace: nclient9-gui.server.ntli.net 944917031 14821 194.168.10.75 (11 Dec 1999 12:57:11 GMT) X-Complaints-To: abuse AT net DOT ntl DOT com NNTP-Posting-Date: 11 Dec 1999 12:57:11 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-Mimeole: Produced By Microsoft MimeOLE V5.00.2615.200 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com You are actually passing the "address of a pointer to char" to the function file_reads(etc). In the function declaration use char ** i.e. void file_reads(int handle,int length,char **dummy) After that you will need to examine each of your references to dummy to make sure you are accessing the right data. This is left as an exercise for the reader ;-) Regards Steve Chalkley Steven Watson wrote in message news:384CD097 DOT B95E1019 AT dtn DOT ntl DOT com... > Hi Everyone > > Is it possible someone can tell me how this code can be written to > change the pointer sent to it > in pow! using a VAR it will make a copy so the value can be changed but > I am unable to figure it out in C? > > int main(void) > char *string; > file_reads(1,5,&string); > printf("%s \n",string); > return 0; > } > function from include file: > > void file_reads(int handle,int length,char *dummy) > { > > > if ((dummy=(char *)malloc(length+1))==NULL){ > puts("Error code here"); > exit(1); > } > > > if((fread(dummy,sizeof(char),length,filehandle[handle]))!=length){ > puts("Put error code here"); > exit(1); > } > *(dummy+length)=0x00; > printf("%s\n",dummy);//it prints here fine as expected. > return; > } > > thanks in advance > Steven Watson