Skip to main content
edited body
Source Link
  1. sprintf cannot be used to write data into String objects. More precisely, it is possible to come up with a "hackish" way to write the result directly into a String object, but the latter is definitely not designed for such use.

The target buffer should 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);
  1. The format string you used in your sprintf will generate %02 outputresult (since i contains 2 at that moment). Why you are expecting 09 is 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.
  2. A String object cannot be used as the first parameter of fprintf. It is not clear what that fprintf is doing in your code.

Apparently you are trying to use sprintf to generate another format string at run time (using i as field width), which is later used to output the d variable. In that case that would be something like

char format[16];
snprintf(format, sizeof format, "%%0%dd", i);
fprintf(file, format, d);

That fprintf will indeed output 09.

  1. sprintf cannot be used to write data into String objects. More precisely, it is possible to come up with a "hackish" way to write the result directly into a String object, but the latter is definitely not designed for such use.

The target buffer should 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);
  1. The format string you used in your sprintf will generate %02 output (since i contains 2 at that moment). Why you are expecting 09 is 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.
  2. A String object cannot be used as the first parameter of fprintf. It is not clear what that fprintf is doing in your code.

Apparently you are trying to use sprintf to generate another format string at run time (using i as field width), which is later used to output the d variable. In that case that would be something like

char format[16];
snprintf(format, sizeof format, "%%0%dd", i);
fprintf(file, format, d);

That fprintf will indeed output 09.

  1. sprintf cannot be used to write data into String objects. More precisely, it is possible to come up with a "hackish" way to write the result directly into a String object, but the latter is definitely not designed for such use.

The target buffer should 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);
  1. The format string you used in your sprintf will generate %02 result (since i contains 2 at that moment). Why you are expecting 09 is 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.
  2. A String object cannot be used as the first parameter of fprintf. It is not clear what that fprintf is doing in your code.

Apparently you are trying to use sprintf to generate another format string at run time (using i as field width), which is later used to output the d variable. In that case that would be something like

char format[16];
snprintf(format, sizeof format, "%%0%dd", i);
fprintf(file, format, d);

That fprintf will indeed output 09.

added 8 characters in body
Source Link
  1. sprintf cannot be used to write data into String objects. More precisely, it is possible to come up with a "hackish" way to write the result directly into a String object, but itthe latter is definitely not designed for such use.

The target buffer should 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);
  1. The format string you used in your sprintf will generate %02 output (since i contains 2 at that moment). Why you are expecting 09 is 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.
  2. A String object cannot be used as the first parameter of fprintf. It is not clear what that fprintf is doing in your code.

Apparently you are trying to use sprintf to generate another format string at run time (using i as field width), which is later used to output the d variable. In that case that would be something like

char format[16];
snprintf(format, sizeof format, "%%0%dd", i);
fprintf(file, format, d);

That fprintf will indeed output 09.

  1. sprintf cannot be used to write data into String objects. More precisely, it is possible to come up with a "hackish" way to write the result directly into a String object, but it is definitely not designed for such use.

The target buffer should 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);
  1. The format string you used in your sprintf will generate %02 output (since i contains 2 at that moment). Why you are expecting 09 is 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.
  2. A String object cannot be used as the first parameter of fprintf. It is not clear what that fprintf is doing in your code.

Apparently you are trying to use sprintf to generate another format string at run time (using i as field width), which is later used to output the d variable. In that case that would be something like

char format[16];
snprintf(format, sizeof format, "%%0%dd", i);
fprintf(file, format, d);

That fprintf will indeed output 09.

  1. sprintf cannot be used to write data into String objects. More precisely, it is possible to come up with a "hackish" way to write the result directly into a String object, but the latter is definitely not designed for such use.

The target buffer should 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);
  1. The format string you used in your sprintf will generate %02 output (since i contains 2 at that moment). Why you are expecting 09 is 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.
  2. A String object cannot be used as the first parameter of fprintf. It is not clear what that fprintf is doing in your code.

Apparently you are trying to use sprintf to generate another format string at run time (using i as field width), which is later used to output the d variable. In that case that would be something like

char format[16];
snprintf(format, sizeof format, "%%0%dd", i);
fprintf(file, format, d);

That fprintf will indeed output 09.

added 2 characters in body
Source Link
  1. sprintf cannot be used to write data into String objects. More precisely, it is possible to come up with a "hackish" way to write the result directly into a String object, but it is definitely not designed for such use.

The target buffer mustshould 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);
  1. The format string you used in your sprintf will generate %02 output (since i contains 2 at that moment). Why you are expecting 09 is 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.
  2. A String object cannot be used as the first parameter of fprintf. It is not clear what that fprintf is doing in your code.

Apparently you are trying to use sprintf to generate aanother format sequencestring at run time, using (using i as field width), which is later used to output the d variable. In that case that would be something like

char format[16];
snprintf(format, sizeof format, "%%0%dd", i);
fprintf(file, format, d);

That fprintf will indeed output 09.

  1. sprintf cannot be used to write data into String objects. More precisely, it is possible to come up with a "hackish" way to write the result directly into a String object, 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);
  1. The format string you used in your sprintf will generate %02 output (since i contains 2 at that moment). Why you are expecting 09 is 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.
  2. A String object cannot be used as the first parameter of fprintf. It is not clear what that fprintf is doing in your code.

Apparently you are trying to generate a format sequence at run time, using i as field width, which is later used to output the d variable. In that case that would be something like

char format[16];
snprintf(format, sizeof format, "%%0%dd", i);
fprintf(file, format, d);

That fprintf will indeed output 09.

  1. sprintf cannot be used to write data into String objects. More precisely, it is possible to come up with a "hackish" way to write the result directly into a String object, but it is definitely not designed for such use.

The target buffer should 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);
  1. The format string you used in your sprintf will generate %02 output (since i contains 2 at that moment). Why you are expecting 09 is 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.
  2. A String object cannot be used as the first parameter of fprintf. It is not clear what that fprintf is doing in your code.

Apparently you are trying to use sprintf to generate another format string at run time (using i as field width), which is later used to output the d variable. In that case that would be something like

char format[16];
snprintf(format, sizeof format, "%%0%dd", i);
fprintf(file, format, d);

That fprintf will indeed output 09.

added 301 characters in body
Source Link
Loading
added 152 characters in body
Source Link
Loading
Source Link
Loading