I created the below program:
#include<stdio.h>
#include<stdlib.h>
#define TESTER "name=%s "
int main(){
char *x;
x = malloc(100);
snprintf(x, 100, "Heyaa tester %s", TESTER, "hello");
printf("%s", x);
free(x)
return 0;
}
I am basically trying to get the output something like - "Hey tester name=hello", However, it seems to be like below:
Heyaa tester name=%s
Do I need to append hello
initially to the macro and then do snprintf
to the malloc'd variable.
Thanks.