char cTime[22];
sprintf(cTime, "%04s/%02s/%2s:%02s:%02s:%02s", year(), month(), day(), hour(), minute(), second());
This sprintf
line causes this error:**B0100000063f694Š
Could someone help me debug this? Thank you.
2 Answers 2
%s is string macro but output of year(),... is probably an integer type. Use %d or %u macros in format.
Yes - try making each of the %-specifiers match the kind of conversion you want for each variable in the rest of the call. F/ex, %d converts an integer to a string in decimal radix, %f converts a double to a number with a decimal fraction, etc. In all cases, the output will be as characters; you don't need to specify that.