www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/25/10:51:24

From: kezman AT nOsPaMbigfoot DOT com (Kieran Farrell)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: URGENT!!! Please (A Little Long)
Message-ID: <381434da.7867638@news.pasteur.dialix.com.au>
References: <3813e85f DOT 18243975 AT news DOT pasteur DOT dialix DOT com DOT au> <004aa0e3 DOT faebcda4 AT usw-ex0101-006 DOT remarq DOT com>
X-Newsreader: Forte Free Agent 1.11/32.235
Organization: DIALix Internet Services
Lines: 48
Date: Mon, 25 Oct 1999 10:56:59 GMT
NNTP-Posting-Host: 203.12.3.8
X-Complaints-To: abuse AT telstra DOT net
X-Trace: nsw.nnrp.telstra.net 940849070 203.12.3.8 (Mon, 25 Oct 1999 20:57:50 EST)
NNTP-Posting-Date: Mon, 25 Oct 1999 20:57:50 EST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Ack Sorry guys, first rule in asking questions on newsgroups. Never
assume people know what you're asking *8)

I made a simple question long winded. In short I'm asking how do I
pass a pointer by refference. Examples for this are opening files, and
adding nodes to linked lists. the later is what I'm trying to achieve.
However heres the file example, it might make more sense.
 
int main(void)
{
    FILE *fp;

    OpenFile(fp);
    return 0;
}

void OpenFile(FILE *fp)
{
    fp = fopen('a:\\yadayad.txt", "wb");
    return;
}

The above wont work, cause whatever pointer is assigned to fp is lost
when the OpenFile procedure is finished.

OK I'll try showing my quick fix again, hopefully it makes more sense
and should compile this time.

int main(void)
{
    FILE *fp;
    
    fp = OpenFile(fp);
    return;
}

FILE *OpenFile(FILE *fp)
{
    fp = fopen('a:\\yadayad.txt", "wb");
    return fp;
}

Oh yeah, this is only a small concept in a large project. It's not
homework *8)


-----
Kieran Farrell

- Raw text -


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