E
Eric Kaplan
I have a function like this
=============
bool Table::Get(char* FieldName, char* FieldValue)
and I call the function like the follow
=============
while(!tbl.ISEOF())
{
char id2[300];
if(tbl.Get("program",id2))
cout<<"program:"<<id2<<endl;
else
{
tbl.GetErrorErrStr(ErrStr);
cout<<"\n"<<ErrStr<<"\n";
break;
}
}
above I passed in a char pointer (char*) - FieldValue and use it just
like a return value.
but it seem not efficient as each time i initialize a char array of
[300] characters.
but some string (FieldValue) is only like [5] char.
how to I do better for returning string? any example code?
=================
should I just return the string in regular return type like -
std::string Table::Get(char* FieldName)
=============
bool Table::Get(char* FieldName, char* FieldValue)
and I call the function like the follow
=============
while(!tbl.ISEOF())
{
char id2[300];
if(tbl.Get("program",id2))
cout<<"program:"<<id2<<endl;
else
{
tbl.GetErrorErrStr(ErrStr);
cout<<"\n"<<ErrStr<<"\n";
break;
}
}
above I passed in a char pointer (char*) - FieldValue and use it just
like a return value.
but it seem not efficient as each time i initialize a char array of
[300] characters.
but some string (FieldValue) is only like [5] char.
how to I do better for returning string? any example code?
=================
should I just return the string in regular return type like -
std::string Table::Get(char* FieldName)