Memory overflow problem?

I am having a problem with this code. When the stuff the following is uncommented (found in the code below):
// if (i==4){
// Long_prime[j] = linea [j+1];
// Serial.print(Long_prime[j]);
// }
//
// if (i==5){
// DirEW[j]=linea[j+1];
// Serial.print(DirEW[j]);
// }
//
// if (i==6){
// vnots[j]=linea[j+1];
// Serial.print(vnots[j]);
// }
//
// if (i==7){
// headin[j]=linea[j+1];
// Serial.print(headin[j]);
// }
//
// if (i==8){
// dateUTC[j]=linea[j+1];
// Serial.print(dateUTC[j]);
// }

I do not get any output in my serial monitor (and there were no errors when compiling).

Could this be a memory overflow problem that i'm having?. Because each of those variables are being assigned length of 300 characters. and if i change the character length to anything less than 300 characters (to solve the memory overflow) i am not able to output any of the variables. For example,
if we have
char dateUTC[299] ="";

and that code .. and then to display it alone i write:

Serial.print(dateUTC);

so when i do that my code will not display the value of dateUTC

could anybody help me finding a way to display these variables withouth having a memory overflow problem (i'm just assuming that this is the problem.. i'm new to arduino).

 #include <string.h>
 #include <ctype.h>
 
 int ledPin = 13;                  // LED test pin
 int rxPin = 0;                    // RX PIN 
 int txPin = 1;                    // TX TX
 int byteGPS=-1;
 char linea[300] = "";
 char comandoGPR[7] = "$GPRMC";
 int cont=0;
 int bien=0;
 int conta=0;
 int indices[13];
 char timeUTC [300] = "";
 char stat [300] = "";
 char Lat_prime[300] = "";
 char Long_prime[300] = "";
 char DirNS[300] = "";
 char DirEW[300] = "";
 char dateUTC[300] = "";
 char vnots [300] ="";
 char headin [300]="";

 void setup() {
   pinMode(ledPin, OUTPUT);       // Initialize LED pin
   pinMode(rxPin, INPUT);
   pinMode(txPin, OUTPUT);
   Serial.begin(4800);
   for (int i=0;i<300;i++){       // Initialize a buffer for received data
     linea[i]=' ';
   }   
 }
 void loop() {
   {
   digitalWrite(ledPin, HIGH);
   byteGPS=Serial.read();         // Read a byte of the serial port
   if (byteGPS == -1) {           // See if the port is empty yet
     delay(100); 
   } else {
     linea[conta]=byteGPS;        // If there is serial port data, it is put in the buffer
     conta++;                      
     Serial.print(byteGPS, BYTE); 
     if (byteGPS==13){            // If the received byte is = to 13, end of transmission
       digitalWrite(ledPin, LOW); 
       cont=0;
       bien=0;
       for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
         if (linea[i]==comandoGPR[i-1]){
           bien++;
         }
       }
       if(bien==6){               // If yes, continue and process the data
         for (int i=0;i<300;i++){
           if (linea[i]==','){    // check for the position of the  "," separator
             indices[cont]=i;
             cont++;
           }
           if (linea[i]=='*'){    // ... and the "*"
             indices[12]=i;
             cont++;
           }
         }
         Serial.println("");      // ... and write to the serial port
         Serial.println("");
         Serial.println("---------------");
         for (int i=0;i<12;i++){
           switch(i){
             case 0 :Serial.print("Time in UTC (HhMmSs): ");break;
             case 1 :Serial.print("Status (A=OK,V=KO): ");break;
             case 2 :Serial.print("Latitude: ");break;
             case 3 :Serial.print("Direction (N/S): ");break;
             case 4 :Serial.print("Longitude: ");break;
             case 5 :Serial.print("Direction (E/W): ");break;
             case 6 :Serial.print("Velocity in knots: ");break;
             case 7 :Serial.print("Heading in degrees: ");break;
             case 8 :Serial.print("Date UTC (DdMmYy): ");break;
             case 9 :Serial.print("Magnetic degrees: ");break;
             case 10 :Serial.print("(E/W): ");break;
             case 11 :Serial.print("Mode: ");break;
             case 12 :Serial.print("Checksum: ");break;
           }
           for (int j=indices[i];j<(indices[i+1]-1);j++){
             
             if (i==0){
               timeUTC[j] = linea[j+1];
               Serial.print(timeUTC[j]);
             }
             
             if (i==1){
              stat[j] = linea [j+1];
             Serial.print(stat[j]);             
             }
             
             if (i==2){
               Lat_prime[j] = linea [j+1];
               Serial.print(Lat_prime[j]);
             }
           
             if (i==3){
              DirNS[j] = linea [j+1];
              Serial.print(DirNS[j]);
             }
             
//             if (i==4){
//              Long_prime[j] = linea [j+1];
//              Serial.print(Long_prime[j]);
//             }
//         
//             if (i==5){
//               DirEW[j]=linea[j+1];
//               Serial.print(DirEW[j]);
//               }
//             
//             if (i==6){
//               vnots[j]=linea[j+1];
//               Serial.print(vnots[j]);
//             }
//             
//             if (i==7){
//               headin[j]=linea[j+1];
//               Serial.print(headin[j]);
//             }
//
//             if (i==8){
//               dateUTC[j]=linea[j+1];
//               Serial.print(dateUTC[j]);
//             }
             
           }
           Serial.println("");
         }
         Serial.println("---------------");
         {
            Serial.println(timeUTC);
            Serial.println(stat);
            Serial.println(Lat_prime);
            Serial.println(DirNS);
            Serial.println("       100");
          }
       }
       
         
       conta=0;                    // Reset the buffer
       for (int i=0;i<300;i++){    //  
         linea[i]=' ';
   timeUTC[i]=' ';
   stat[i]=' ';
Lat_prime[i] =' ';
DirNS[i]=' ';
//Long_prime[i]=' ';
//DirEW[i]=' ';
//dateUTC[i]=' ';
       }                 
     }
   }
 }

 }
for (int j=indices[i];j<(indices[i+1]-1);j++){

             if (i==0){
               timeUTC[j] = linea[j+1];
               Serial.print(timeUTC[j]);
             }

Why would you want to put the data from linea somewhere in the middle of timeUTC?

Suppose indices[0] contains 23 and indices[1] contain 31. The values of j will range from 23 to 30, and the values in linea[23] through linea[30] will be copied into timeUTC[22] through timeUTC[29].

Why wouldn't you copy them to timeUTC[0] through timeUTC[7]?

There is no reason for timeUTC or any of the other arrays, except linea, to be 300 characters long.

The difference between a character array and a string is that a string is a character array that is NULL terminated.

None of your character arrays are NULL terminated, so you have no strings. The Serial.print statements that you are passing a character array to are expecting the data to start in position 0 and to be NULL terminated.

None of your arrays meet this criteria, so the failure to print anything is not unexpected.

You really need to look into pointers. You've got an array of characters. Null terminate it, and you have a string. Use the strtok command to parse the string, rather than trying to write your own parser. It's professionally written, by people that know what they are doing. It returns pointers to NULL terminated strings.

At the end of the loop that read the character data (to become a string), the pointers are no longer needed, so you can just let them go out of scope, since no space was actually allocated for the string that they point to.

You'll use a lot less memory, since the pointer to timeUTC points to a position in linea, rather than it's own memory space.