M
Mike Copeland
How can I use std::string parameters (as return data) in subprogram
calls? In the following routine, I have 1 input and 3 output arguments:
void getPhaseData(int pNum, string X, string Y, short *T)
{
switch (pNum)
{
case 0:
{
X = "Null Phase", Y = "", *T = NPTyp;
break;
}
case 1:
{
X = "Run Finish", Y = " Run", *T = FPTyp;
break;
}
case 2:
{
X = "Bike Finish", Y = "Bike", *T = FPTyp;
break;
}
[etc.]
}
return;
} // getPhase_Data
This doesn't work, because the 2 string arguments are returned as
NULL. The problem has occurred as I try to convert very old code (20+
years) to more modern C++ code, using STL containers and such. The old
code used C strings and pointers, but I can't get this code to work.
Please advise. TIA
calls? In the following routine, I have 1 input and 3 output arguments:
void getPhaseData(int pNum, string X, string Y, short *T)
{
switch (pNum)
{
case 0:
{
X = "Null Phase", Y = "", *T = NPTyp;
break;
}
case 1:
{
X = "Run Finish", Y = " Run", *T = FPTyp;
break;
}
case 2:
{
X = "Bike Finish", Y = "Bike", *T = FPTyp;
break;
}
[etc.]
}
return;
} // getPhase_Data
This doesn't work, because the 2 string arguments are returned as
NULL. The problem has occurred as I try to convert very old code (20+
years) to more modern C++ code, using STL containers and such. The old
code used C strings and pointers, but I can't get this code to work.
Please advise. TIA