Anyway your problem is a problem of scope and/or misunderstanding pointers.
In your parseCmdLine function, you're changing 'workDir' to point to 'tempPath'. When the function exits, 'tempPath' is destroyed because it is a local variable, and therefore 'workDir' becomes a bad pointer because what it points to no longer exists.
You're better off using strings:
1 2 3 4 5 6 7 8 9 10
string workDir;
//...
int parseCmdArg( unsignedshort &tcp_port, string& workDir, int argc, char* argv[])
{
//..
workDir = tempPath;
//..
}