pesky pointer problems...

The whole project involves dozens of libraries and custom hardware so posting something that can easily be run on another arduino probably isn't practical. The original getPhone() function is based on a library that reads from a file on an SD card. That library itself is then based on a dozen others. I'll try to give an explanation here of how it all hangs together....

The two getPhone() functions are defined in the ConfigMan library....

char * ConfigMan::getPhone(byte num)
{
  // If the file isn't already open, then open it.
  if (opened == false)
  {
    // open the config file tracker.txt
    open();
  }

  // Look up the value for glider ID in the file tracker.txt
  sprintf_P(_tag,CREW_NO,num);
  _configFile.getTagValue(_tag,_tempTagVal);

  if ( strlen(_tempTagVal) != 0 )
  {
    // hmmmm...
  }
  close();
  return _tempTagVal;
}


/*
 * Same functionality as previous version, but validates the phone number and
 * returns true if it looks ok. Return false if the number doesn't exist or isn't
 * a sensible phone number.
 */
bool ConfigMan::getPhone(byte num, char* crewPhone)
{
  crewPhone=getCrew(num);

  // Check that the length of the phone number is within acceptable limits
  if ((strlen(crewPhone) <= _minPhoneLen) || (strlen(crewPhone) > _maxPhoneLen) )
  {
    // Phone number is too short (or long) to be plausable
    return false;
  }
  else
  {
    return true;
  }
}

The ConfigMan library is used in the Dispatcher library by a function with the following prototype....

byte processTop(ConfigMan* p_configMan, 
                       MessMan* p_messMan, 
                       MiniGPS* p_miniGps,
                       char *Id);

so the first parameter in processTop is a pointer to an object based on the ConfigMan library.
This function contains a pointer to a character array...
char * p_phoneNo;  // Pointer to phone number
and the following line.....

if (p_configMan->getPhone(crewNum,p_phoneNo) == true)
      {
// do stuff
}

The above snipet is at the crux of the problem, when getPhone() returns true, p_phoneNo should point to a string array containing a phone number - it seems to actually point to a single random character.

In my top level arduino sketch I declare an object called 'dispatch1' of type Dispatcher....

Dispatcher dispatch1;

And an object called 'configMan1' of type ConfigMan...

ConfigMan confMan1;

I then invoke the processTop() function with the following line....

byte res=dispatch1. processTop (&confMan1, &mess1, &gps1,ID);

So I'm passing my Dispatcher object the address of my ConfigMan object.

Sorry I can't post a simple working example (or even a simple not-working example) the only way could do this is by publishing the whole project and sending the hardware! I'm trying to work on a simple cut-down version of the code to publish but this may take some time.