Article View: comp.sys.ibm.pc.programmer
Article #1022Returning a char* in Turbo C:
From: Michael Rice
Date: Mon, 30 Jul 1990 05:02
Date: Mon, 30 Jul 1990 05:02
45 lines
1436 bytes
1436 bytes
I wrote the following code to return a char* (a character pointer)
to a string let's say "Michigan". I went through the debugger and
the return value tempv->vname is correct but it returns something
else something like "\eu\r4" which is gibberish to me.
I am mainly calling it like this:
printf("%s",findvolname(temp));
where temp is a ENTRYPTR type... Any ideas what is wrong? I only have
problems when I try to return char*, not when I return integers or floats..
Any help is appreciated...
Here is the function:
#include "prog.h"
#include <stdio.h>
#include <dos.h>
extern VOLUMEPTR topvollist;
char *findvolname(enode)
ENTRYPTR enode;
{
VOLUMEPTR vtemp;
int done = 0;
vtemp = topvollist->nextvolume;
while(vtemp != NULL && !done)
{
if(vtemp->index == enode->volume_index)
{
done = 1;
}
else
{
vtemp = vtemp->nextvolume;
}
}
return(vtemp->vname);
}
Technical Details
Message-ID:
<1990Jul30.050221.29945@caen.engin.umich.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!sharkey!math.lsa.umich.edu!caen!magnolia.engin.umich.edu!mriceShow Full Headers
Complete Article Headers
Newsgroups: comp.sys.ibm.pc.programmer Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!sharkey!math.lsa.umich.edu!caen!magnolia.engin.umich.edu!mrice From: mrice@caen.engin.umich.edu (Michael Rice) Subject: Returning a char* in Turbo C: Message-ID: <1990Jul30.050221.29945@caen.engin.umich.edu> Keywords: Turb Sender: news@caen.engin.umich.edu (CAEN Netnews) Organization: University of Michigan Engineering, Ann Arbor Date: Mon, 30 Jul 90 05:02:21 GMT