help on C++ programming .. character overflows

 

Hi
I am using Visual 6 C++ and try to retrieve a member's all closed trades. i declare a string as below:

char str[8000]={0};

But this declaration is ok and the program work fine if the member's record size does not exceed 8000bytes.

In order to be able to retrieve member's record where total size more than 8000, i have declare as below:

char *str = new char();

This declaration works fine but it hang my server. Whenever i execute this API with this declaration, my MT4 server will hang, and its service cannot restarted. We have to restart the server.

Is there any way or any example where i can return big volume data?

Thanks.

My main code to retrieve data as below:

trades=ExtServer->OrdersGetClosed(start, end,userlogins,1, &total);

//OrdersGetClosed(const time_t from,const time_t to,const int *logins,const int count,int* total);

// check orders
for(j=0; j<total; j++)
{
if(strcmp(GetCmd(trades[j].cmd), "credit")!=0 && strcmp(GetCmd(trades[j].cmd), "balance")!=0)
{
sprintf(tmp,"%d",trades[j].order);
strcat(str,tmp);
strcat(str,",");
sprintf(tmp,"%d",trades[j].login);
strcat(str,tmp);
strcat(str,",");
FormatDateTime(trades[j].open_time,tmp,sizeof(tmp)-1,TRUE,TRUE);
strcat(str,tmp);
strcat(str,",");
strcat(str, GetCmd(trades[j].cmd));
strcat(str,",");
COPY_STR(tmp, trades[j].symbol);
_strlwr(tmp);
strcat(str, tmp);
strcat(str,",");
sprintf(tmp,"%.2lf",trades[j].volume/100.0);
strcat(str,tmp);
strcat(str,",");
ToSymExt(tmp, trades[j].open_price, trades[j].digits);
strcat(str, tmp);
strcat(str,",");
FormatDateTime(trades[j].close_time,tmp,sizeof(tmp)-1,TRUE,TRUE);
strcat(str,tmp);
strcat(str,",");
ToSym(tmp, trades[j].close_price, trades[j].digits);
strcat(str, tmp);
strcat(str,",");

strcat(str, ToMoney(trades[j].commission, 2, tmp, sizeof(tmp)-1));
strcat(str,",");
strcat(str, ToMoney(trades[j].taxes, 2, tmp, sizeof(tmp)-1));
strcat(str,",");
strcat(str, ToMoney(trades[j].commission_agent, 2, tmp, sizeof(tmp)-1));
strcat(str,",");
strcat(str, ToMoney(trades[j].storage, 2, tmp, sizeof(tmp)-1));
strcat(str,",");
strcat(str, ToMoney(trades[j].profit, 2, tmp, sizeof(tmp)-1));
strcat(str,",");
mul=Decimals(trades[j].digits);
if(trades[j].cmd==OP_BUY)
pips=NormalizeDouble(trades[j].close_price*mul,0)-NormalizeDouble(trades[j].open_price *mul,0);
else
pips=NormalizeDouble(trades[j].open_price *mul,0)-NormalizeDouble(trades[j].close_price*mul,0);

sprintf(tmp,"%d", int(pips));
strcat(str, tmp);
strcat(str,",");
strcat(str, trades[j].comment);

strcat(str,"\n");
}

}
strcat(str,"end\r\n");
//---- clear
HEAP_FREE(trades); trades=NULL;
if(strlen(str)==0)
return _snprintf(buffer,size-1,"ERROR\r\nNo Orders for %d\r\nend\r\n", userlogin);
else
return _snprintf(buffer,size-1,"%s", str);

MT4 is using native dll..my VC6 cant seem to compile using the string.. i include in my header file but still give me an error.. any other way to solve the problem ?

any solutions would be greated appreicated

Reason: