Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pointer calling trouble

Status
Not open for further replies.

ozgurgul

Programmer
Joined
Mar 15, 2004
Messages
4
Location
EU
I have a function :) and I want to use it but I dunno how to call it (I am a poor guy with having trouble that pointers)
please help me...
mmm... thanks!!

void MyClass::parseFilename(const char* fname, char** dir, char** name, char** ext)
{
// special case
if (fname == NULL)
{
if (dir != NULL) *dir = newstr("");
if (name != NULL) *name = newstr("");
if (ext != NULL) *ext = newstr("");
}

char* newfname = newstr(fname);

char* lastsep = strrchr(newfname, '\\');
char* lastdot = strrchr(newfname, '.');
if (lastsep != NULL) *lastsep = '\0';
if (lastdot != NULL && lastdot > lastsep) *lastdot = '\0';

if (dir != NULL) *dir = newstr(newfname);

if (name != NULL)
{
if (lastsep != NULL) *name = newstr(lastsep + 1);
else *name = newstr("");
}

if (ext != NULL)
{
if (lastdot != NULL && lastdot > lastsep) *ext = newstr(lastdot + 1);
else *ext = newstr("");
}

delete[] newfname;
}
 
Hi,

I would do something like this :

Code:
  MyClass a;//instantiate it(see the constructors)

  char* dir = NULL;
  char* name = NULL;
  char* ext = NULL;

  a.parseFilename ("afilename.txt", &dir, &name, &ext);

--
Globos
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top