i have these variables:
char server[] = "myserver.hol.es";
int num = 12345;
how can i join them into "myserver.hol.es/12345"?
i have these variables:
char server[] = "myserver.hol.es";
int num = 12345;
how can i join them into "myserver.hol.es/12345"?
Or 'sprintf_P()', to store the format string in program memory:-
void setup()
{
Serial.begin(115200);
char server[] = "myserver.hol.es";
int num = 12345;
char buffer[25];
sprintf_P(buffer, PSTR("%s/%i"), server, num);
Serial.println(buffer); // Prints: "myserver.hol.es/12345"
}
i try these code but the output was 518/12345
char server[]="myserver.com";
int num = 12345;
char buffer[50];
void setup(){
Serial.begin(9600);
sprintf(buffer,"%d/%d",server,num);
Serial.print(buffer);
}
void loop(){
}
ohhh,, thank you for your reply,, its work... i dont see your reply when i write my previous reply...
patrixx:
ohhh,, thank you for your reply,, its work... i dont see your reply when i write my previous reply...
Oh good.
What you did wrong in your last post was that this "%d/%d" should have been "%s/%i".
'%s' is string
'%i' is integer
All's well that ends well.