I have certain string processing to do , the approach I am using is in following sample -
Void ProcessObjects(int nObject)
{
std::string sInfostr;
for(int i = 0;i<nObject;i++)
{
InfoObject Inf = new InfoObject;
GetInfoObject(&Inf);
GetStoredInformation(Inf, std::string &sInfostr)
delete Inf;
}
}
void GetStoredInformation(InfoObject Inf, std::string &sInfostr)
{
char tag[1000];
GetInformation(&Inf);
sprintf(tag, "name=%s",Inf.name);
sInfostr += tag;
sprintf(tag, "name1=%s",Inf.name1);
sInfostr += tag;
sprintf(tag, "name2=%s",Inf.name2);
sInfostr += tag;
sprintf(tag, "name3=%s",Inf.name3);
sInfostr += tag;
sprintf(tag, "name4=%s",Inf.name4);
}
Now can I get some suggestion is it a good way to process string? Will I code go in any trouble if "nObject" above 10,000?
GetInfObject()andGetStoredInformation()methods ofInfoObject?name,name1....name4all asstd::string?InfoObject Inf = GetInfoObject();is simpler and probably also more efficient than what you are doing.