ESP8266 Developer Zone The Official ESP8266 Forum 2016-07-05T16:52:58+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=2388 2016-07-05T16:52:58+08:00 2016-07-05T16:52:58+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2388&p=7750#p7750 <![CDATA[Re: Problem with os_strcat and char-array]]>
Please explicitly initialize all variables and dynamically allocated memory for reliable code behavior. You still have to follow all the basic rules related to variables in C to avoid compiler specific problems.

Statistics: Posted by Guest — Tue Jul 05, 2016 4:52 pm


]]>
2016-07-05T15:09:03+08:00 2016-07-05T15:09:03+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2388&p=7735#p7735 <![CDATA[Re: Problem with os_strcat and char-array]]>
I found out, that this works also very well:

Code:

os_sprintf(requestText, "GET /mySQLFunction.php?action=insert&value=%d / HTTP/1.1\r\nUser-Agent: curl/7.37.0\r\nHost: %s\r\nAccept: */*\r\n\r\n",adcRead,NET_DOMAIN);

Statistics: Posted by Stational — Tue Jul 05, 2016 3:09 pm


]]>
2016-07-05T10:44:20+08:00 2016-07-05T10:44:20+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2388&p=7727#p7727 <![CDATA[Re: Problem with os_strcat and char-array]]>
Stational wrote:
Hello,

this is my attempt to create a HTTP Get request header:

Code:

   char requestText[120];
   strcat(requestText, "GET /myPHP.php?action=insert&value=");
   strcat(requestText, adcValue);
   strcat(requestText, "/ HTTP/1.1\r\nUser-Agent: curl/7.37.0\r\nHost: ");
   strcat(requestText, NET_DOMAIN);
   strcat(requestText, "\r\nAccept: */*\r\n\r\n");


this is what i get if i use

Code:

os_printf(requestText);



Ô
@T«GET /myPHP.php?action=insert&value=155/ HTTP/1.1
User-Agent: curl/7.37.0
Host: http://www.myHost.org
Accept: */*


I don't know where these strange chars in front of the 'GET' come from? How do i get rid of them?

You should add

Code:

memset(requestText, 0, 120);
before strcat
or you can change

Code:

char requestText[120];
to

Code:

char requestText[120] = {0};

Statistics: Posted by tobewinner — Tue Jul 05, 2016 10:44 am


]]>
2016-07-04T19:35:52+08:00 2016-07-04T19:35:52+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2388&p=7718#p7718 <![CDATA[[SOLVED] Problem with os_strcat and char-array]]>
this is my attempt to create a HTTP Get request header:

Code:

   char requestText[120];
   strcat(requestText, "GET /myPHP.php?action=insert&value=");
   strcat(requestText, adcValue);
   strcat(requestText, "/ HTTP/1.1\r\nUser-Agent: curl/7.37.0\r\nHost: ");
   strcat(requestText, NET_DOMAIN);
   strcat(requestText, "\r\nAccept: */*\r\n\r\n");


this is what i get if i use

Code:

os_printf(requestText);




Ô
@T«GET /myPHP.php?action=insert&value=155/ HTTP/1.1
User-Agent: curl/7.37.0
Host: http://www.myHost.org
Accept: */*


I don't know where these strange chars in front of the 'GET' come from? How do i get rid of them?

Statistics: Posted by Stational — Mon Jul 04, 2016 7:35 pm


]]>