trouble with char variable when reading from SD and joining chars

I have text file have which have only one line exactly like this: “00004624127540018”
I try to read this file char by char and split this char to 3 variables tTime should have first 8 char from file, tTimeP should have 5 char (9 to 14 from file) and last 4 should be in count variable
tTime and count are OK but…
Why tTimeP have at the and and why have length = 6?

I also attached my sketch and file from SD
also here is pastebin with C++ highlighting

#include <SD.h>
File myFile;
void setup() {
  // put your setup code here, to run once:
//pinMode(15, OUTPUT);
  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
  Serial.println("initialization done.");
  // re-open the file for reading:
  myFile ="wyciag.log");
  if (myFile) {
    // read from the file until there's nothing else in it:
    char tTime[8];
    char tTimeP[5];
    char count[4];
    char tempC[30];
    int x = 0;
    int a = 0;
    int b = 0;
    int c = 0;
    while (myFile.available()) {
     char z =;
    tempC[x] = z;
      if (x <8) {
        tTime[a] = z;
      } else if ((x >7) && (x < 13)) {
        tTimeP[b] = z;
      } else if (x>12) {
        count[c] = z;
    Serial.print("a = ");
    Serial.print("b = ");
    Serial.print("c = ");
    Serial.print("tTime len = ");
    Serial.print("tTimeP len = ");
    Serial.print("count len = ");
    Serial.print("tTime = ");
    Serial.print("tTimeP = ");
    Serial.print("count = ");
    Serial.print("tempC = ");
    // close the file:
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
void loop() {
  // put your main code here, to run repeatedly:
Port Monitor output
Initializing SD card...initialization done.
a = 8
b = 5
c = 4
tTime len = 8
tTimeP len = 6
count len = 4
tTime = 00004624
tTimeP = 12754
count = 0018
tempC = 00004624127540018 (1.07 KB)

I ask friend to test my sketch on his arduino and he have same problem, anyone can help?

You are using strlen on arrays that are not c strings. They do not have null termination.

You can make all the arrays one element longer and make the last one '\0'.

Alternatively, use sizeof for the length of the array.

I spent 5h+ trying resolve reading/writing to SD file and almost all the time I spent trying “remove” this square from end of tTimeP.
When I change srtlen to sizeof (like you say) then it show 5 for tTimeP how the hell explain this last (6-th) char/square whatever is it?
also what this “magic” sign ‘\0’ mean?

also what this “magic” sign ‘\0’ mean?

It is the null terminator for a c style string.

There are several useful functions, like strlen, which manipulate these c strings, and they expect the null terminator.

You need to do some google search on c++ String object, spelled with a capital S, and the c string, spelled with a small s.

Because of the limited memory in an Arduino, most of the advice you will get on this forum is to use null terminated character arrays (strings) and not the String Object (String).