Problme mit decoding char array

Hi, I wrote a function, I can enter a char array with. For example the array:

char array[] = {'5','2','.','5','2','1','N','1','0','.','2','6','2','8','E'};

And I want to decode it to: "52.521" and "10.2628" Then I want to convert it to float with atof. This is the part from the function:

char lat[10];
        char lon[10];
        i = 0;
        while(input_data[i]!='N'){
          lat[i] = input_data[i];
          i++;
        }
        lat[i] = '\0';
        i++;
        int e=0;
        while(input_data[i]!='E'){
          lon[e] = input_data[i];
          i++;
          e++;
        }
        lon[e] = '\0';
        waypoint_lat[n] = atof(lat);
        waypoint_lon[n] = atof(lon);
        return 1;

The input_data char array is the arry with the incoming data from me. But its not working. Can somebody please help me?

Greetings Philipp

Maybe you can use this sketch as a starter:

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

void loop()
{
    char input_data[] = {
        '5','2','.','5','2','1','N',
        '1','0','.','2','6','2','8','E'
    };
    char lat[20];
    char lon[20];

    int i = 0;
    while(input_data[i]!='N'){
        lat[i] = input_data[i];
        i++;
    }
    lat[i] = '\0';
    i++;
    int e=0;
    while(input_data[i]!='E'){
        lon[e] = input_data[i];
        i++;
        e++;
    }
    lon[e] = '\0';
    
    Serial.println("Strings:");
    Serial.print("lat: ");
    Serial.println(lat);
    Serial.print("lon: ");
    Serial.println(lon);
    Serial.println();
    
    float waypoint_lat = atof(lat);
    float waypoint_lon = atof(lon);
    Serial.println("Floats:");
    Serial.print("waypoint_lat = ");
    Serial.println(waypoint_lat, 4);
    Serial.print("waypoint_lon = ");
    Serial.println(waypoint_lon, 4);
    Serial.println();
    
    delay(10000);
}

Output:


Strings:
lat: 52.521
lon: 10.2628

Floats:
waypoint_lat = 52.5210
waypoint_lon = 10.2628

Regards,

Dave