B
B
blormik2014-10-07 09:13:00
Arduino
blormik, 2014-10-07 09:13:00

How to merge into one value Char int Char in arduino (c++)?

there are 3 variables

char mes="message";
int point = 10; //Любое число
char ="message2";

It is necessary to combine all this into one variable of type char or uint8_t and pass the function
Client.write()
Which is declared as follows
size_t write(uint8_t);
  size_t write(const uint8_t *buf, size_t size);

Answer the question

In order to leave comments, you need to log in

4 answer(s)
G
GavriKos, 2014-10-07
@GavriKos

I don’t know how it is in arduins, but in normal c / c ++ you can use the following functions:
- printf
- memcpy

D
dummy2002, 2014-10-07
@dummy2002

Haven't worked with arduinos, but in C it's usually done via structs and then passed a reference to the struct to the function. Try looking at a similar example here

T
Tolik, 2014-10-07
@Diel

If the compiler understands the asprintf function (either like cstdio (or stdio.h)) then you can glue it like this:
char *fullString;
asprintf(&fullString, "%s%d%s", msg1, number, msg2);
client.write(fullString);
formatting for this function such as in printf() and similar ones

S
starikstd, 2014-11-19
@starikstd

char mes='message';
int point = 10; 
String per = String(mes) + String(point) ;
Serial.print(per);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question