Mail Archives: djgpp/1999/10/25/10:51:24
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 -