sprintfcannot be used to write data intoStringobjects. More precisely, it is possible to come up with a "hackish" way to write the result directly into aStringobject, but it is definitely not designed for such use.
The target buffer must be an array of char, not a String. Which is what the compiler is telling you.
char buffer[64]; sprintf(buffer, "%%0%d", i); or better
char buffer[64]; snprintf(buffer, sizeof buffer, "%%0%d", i); - The format string you used in your
sprintfwill generate%02output (sinceicontains2at that moment). Why you are expecting09is not clear. Why are you expecting the%character to disappear is not clear either, considering that the format string seems to be deliberately designed to include it. - A
Stringobject cannot be used as the first parameter offprintf. It is not clear what thatfprintfis doing in your code.