I have the following C
example:
char *message;
char *name = "John";
int age = 100;
message = "Hello, I am John, age 100";
How to put name
and age
as parameters in message
?
Pseudo codemessage = "Hello, I am {name}, age {age}"
UPDATE
I tried the following example from comments:
char *body = "{ \"capabilities\": {},\"desiredCapabilities\": {}}";
int content_length = sizeof(body);
char *format = "POST /session HTTP/1.1\r\nContent-Type: application/json\r\nContent-Length:%d\r\n\r\n%s";
int len = snprintf(NULL, 0, format, content_length, body);
char *message = malloc(len + 1);
snprintf(message, len + 1, format, content_length, body);
But I am getting error at char *message = malloc(len + 1);
:
error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]|