-->
Page 1 of 1

How to concat two strings without overwriting any of them?

PostPosted: Wed Nov 18, 2015 2:25 am
by ashubhatt
Hey guys,

I am trying to create MQTT subscription strings, to which ESP module should subscribe. I have tried using strcat, but it replaces the original string.

I want the string to include the ESP8226 chip id in the subscribe string.
Ex: "ESP_182648/gpio/0".
But it overwrites the source string "ESP+182648" when I use strcat.

Any solution?

Re: How to concat two strings without overwriting any of the

PostPosted: Wed Nov 18, 2015 3:36 am
by eduperez
Have a look at "sprintf".

Re: How to concat two strings without overwriting any of the

PostPosted: Wed Nov 18, 2015 4:00 am
by Aakash Sancheti
For LUA script you can use '..'

Example: String3 = String1 .. String2
A = '1' .. '9'
A = '19'

I hope this serves the purpose.