Getting crashes when doing simple strings parsing


i keep getting strange results every time trying things using strings , pointers.

i have function :


code: [select]
void parsegetrequest(char* data)
{

             string parseget=data;
             string from="get /";
             string to="http";
             int ind1 = parseget.indexof(from);
             int ind2 = parseget.indexof(to);
             parseget=parseget.substring(ind1+from.length(), ind2-1);
             strcpy(data, parseget.c_str () );

}




why getting strange behaviour when using ? brings results, garbage, chip reseting .


this how use :

code: [select]
   uint8_t buffer[128] = {0};
    uint8_t mux_id;
    uint32_t len = wifi.recv(&mux_id, buffer, sizeof(buffer), 100);
     char serverdata[100]={0};

   
    if (len > 0)
    {
       
        for(uint32_t = 0; < len; i++)
           serverdata[i]=(char)buffer[i];
           
       

        parsegetrequest( serverdata );
 


quote
sometimes chip reseting .
that might power issue, or maybe in code did not post.


Arduino Forum > Using Arduino > Programming Questions > Getting crashes when doing simple strings parsing


arduino

Comments