[comp.sys.ibm.pc.programmer] Returning a char* in Turbo C:

mrice@caen.engin.umich.edu (Michael Rice) (07/30/90)

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);

}