I would like to use the syntax that printf uses, using the %d, %s and adding values after to assign a value to a char[]. Is this possible?
e.g. Given an output of:
printf("now: %d-%d-%d %d:%d:%d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
I'd like to assign that to char[] output;
How can this be done?
I tried:
sprintf(output, "now: %d-%d-%d %d:%d:%d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
but that didn't seem to work. Is sprintf used differently... or is that not what I should be using?
Thanks!