String with variable of fixed lenght

Make a test sketch and play with it :wink: It's what I usually do (more or less).

Thanks guys for your help! Did learn much I did'nt know!

sterretje:
Make a test sketch and play with it :wink: It's what I usually do (more or less).

But for me personally I need to understand the bigger picture first.

That's what I came up with. Any ideas on it (besides the size of the array)?

There are max 56 sensors so I'm not that happy with:

for (int i = 0; i < 60; i = i + 10)

but it works.

// ----- Error Email Body definition ------------------------------------------------------
#define Zeile1 "\nLETZTE MESSWERTE:\n\n"
#define ZWass "Wasserstand Tank: "
// #define ZDWass "Wasserstand DĂźngermix: "     // Erstmal ausgelassen
#define ZTemp "Temperatur (°C): "
#define ZLight "Helligkeit: "
#define ZSensTitle "\n\nFeuchtigkeitssensoren:\n"
#define ZTrenn "___________________________________________________________\n"
#define ZPot "Topf:    "
#define ZRead "Messwert:"
#define ZHinw "Hinweis: Sensorfehler oder fehlende Kalibration = -1"
// ----------------------------------------------------------------------------------------

int AnzToepfe = 56;
int WassMAP = 100;
int Temperatur = 25;                              // durch ReadTemp(); ersetzen
int Helligkeit = 70;                                 // durch gemappte Helligkeit ersetzen
char MailString[2048] = {};                     // Mailinhalt

int FeuchtigkeitMAP[56] = {
  100, 200, 300, 400, 500, 600, 700, 800,
  900, 110, 120, 130, 140, 150, 160, 170,
  180, 190, 210, 220, 230, 240, 250, 260,
  270, 280, 290, 310, 320, 330, 340, 350,
  360, 370, 380, 390, 410, 420, 430, 440,
  450, 460, 470, 480, 490, 510, 520, 530,
  540, 550, 560, 570, 580, 590, 610, 620
};

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  sprintf(MailString, Zeile1 ZWass "%d\n" ZTemp "%d\n" ZLight "%d\n" ZSensTitle ZTrenn, WassMAP, Temperatur, Helligkeit);
  for (int i = 0; i < 60; i = i + 10)
  {
    if (i < AnzToepfe)
    {
      sprintf(MailString + strlen(MailString), ZPot);
      // ---------------------------------------------------------------------------------
      for (int j = 0; j < 10; j++)
      {
        if (j + i < AnzToepfe)
        {
          sprintf(MailString + strlen(MailString), "%5d" , j + i + 1);
        }
        else
        {
          break;
        }
      }
      sprintf(MailString + strlen(MailString), "\n" ZRead);
      for (int j = 0; j < 10; j++)
      {
        if (j + i < AnzToepfe)
        {
          sprintf(MailString + strlen(MailString), "%5d" , FeuchtigkeitMAP[0 + j + i]);
        }
        else
        {
          break;
        }
      }
      sprintf(MailString + strlen(MailString), "\n" ZTrenn);
      // ---------------------------------------------------------------------------------
    }
  }
  sprintf(MailString + strlen(MailString), "\n\n" ZHinw);



  Serial.println("\n\n\n---------------------------------------------------------------------------------------------");
  Serial.print("String Länge: ");
  Serial.println(strlen(MailString));
  Serial.println("String: ");
  Serial.println("---------------------------------------------------------------------------------------------");
  printf(MailString);
  delay(10000);
}

Gorkde:
I noticed buffer is marked by Arduino IDE

The reason is the Bridge library has a buffer function so it's in that library's keywords.txt. This has no relevance to your code but the Arduino IDE still highlights it.