hello ESP Geeks,
I am modifing a http_client example
const char *post_data = "field1=value1&field2=value2";
esp_http_client_set_url(client, "http://httpbin.org/post");
I want to concat Integer value to field1 like "field1=656565"
I am not able to do facing some problem due to my weakness with pointers.
Please Help..
C concat
Re: C concat
Something like
const char *post_data;
asprintf(&post_data, "field1=%d&field2=%d", value1, value2);
....
free(post_data);
(where value1 value2 are ints)
const char *post_data;
asprintf(&post_data, "field1=%d&field2=%d", value1, value2);
....
free(post_data);
(where value1 value2 are ints)
Re: C concat
If you want to use code that does not call malloc:
char tmp[32];
snprintf(tmp, sizeof(tmp), "%d %d", val2, val2); // val1 and val2 are your integers
char tmp[32];
snprintf(tmp, sizeof(tmp), "%d %d", val2, val2); // val1 and val2 are your integers
Re: C concat
hello
asprintf(&post_data, "field1=%d&field2=%d", value1, value2);
....
free(post_data);
This is eating away Heap memory
Why free is not working ?
asprintf(&post_data, "field1=%d&field2=%d", value1, value2);
....
free(post_data);
This is eating away Heap memory
Why free is not working ?
Who is online
Users browsing this forum: No registered users and 93 guests