sscanf(input_str, \"%5s\", buf); //reads at max 5 characters from input_str to buf
But I need to use something like %MACRO_SIZEs instead of %5s
if your MACRO_SIZE is const at compile time, you can try this:
#define MACRO_SIZE "5" snprintf(fmt_str, 100, "%" MACRO_SIZE "s", buf);