Strange behaviour of Serial.print

Hello,

I need to use a string array for my project and I encounter some strange behavior
With the stdio output.

1 The stdio output stop even the whole code is not executed.

2 Some strange caracters appears like in line “Cde N° 003”

I have to precise I’m using an ARDUINO YUN under the 1.8.6 IDE Release.

Thanks for your help….

Bests Regards…..

String String_Array[ ]  { "Cde N° 001\t+++\n" , "Cde N° 002\tATRE\n" , "Cde N° 003\tATID2468\n" , "Cde N° 004\tATCE1\n" , "Cde N° 005\tATCE1\n" , "Cde N° 006\tATSL\n" , "Cde N° 007\tATDH0013A200\n" , "Cde N° 008\tATDL4177E10A\n" , "Cde N° 009\tATAP0\n" , "Cde N° 010\tATWR\n" ,
                          "Cde N° 011\t+++\n" , "Cde N° 012\tATRE\n" , "Cde N° 013\tATID2468\n" , "Cde N° 014\tATCE1\n" , "Cde N° 015\tATCE1\n" , "Cde N° 016\tATSL\n" , "Cde N° 017\tATDH0013A200\n" , "Cde N° 018\tATDL4177E10A\n" , "Cde N° 019\tATAP0\n" , "Cde N° 020\tATWR\n" ,
                          "Cde N° 021\t+++\n" , "Cde N° 022\tATRE\n" , "Cde N° 023\tATID2468\n" , "Cde N° 024\tATCE1\n" , "Cde N° 025\tATCE1\n" , "Cde N° 026\tATSL\n" , "Cde N° 027\tATDH0013A200\n" , "Cde N° 028\tATDL4177E10A\n" , "Cde N° 029\tATAP0\n" , "Cde N° 030\tATWR\n" ,
                          "Cde N° 031\t+++\n" , "Cde N° 032\tATRE\n" , "Cde N° 033\tATID2468\n" , "Cde N° 034\tATCE1\n" , "Cde N° 035\tATCE1\n" , "Cde N° 036\tATSL\n" , "Cde N° 037\tATDH0013A200\n" , "Cde N° 038\tATDL4177E10A\n" , "Cde N° 039\tATAP0\n" , "Cde N° 040\tATWR\n" ,
                          "Cde N° 041\t+++\n" , "Cde N° 042\tATRE\n" , "Cde N° 043\tATID2468\n" , "Cde N° 044\tATCE1\n" , "Cde N° 045\tATCE1\n" , "Cde N° 046\tATSL\n" , "Cde N° 047\tATDH0013A200\n" , "Cde N° 048\tATDL4177E10A\n" , "Cde N° 049\tATAP0\n" , "Cde N° 050\tATWR\n" ,
                          "Cde N° 051\t+++\n" , "Cde N° 052\tATRE\n" , "Cde N° 053\tATID2468\n" , "Cde N° 054\tATCE1\n" , "Cde N° 055\tATCE1\n" , "Cde N° 056\tATSL\n" , "Cde N° 057\tATDH0013A200\n" , "Cde N° 058\tATDL4177E10A\n" , "Cde N° 059\tATAP0\n" , "Cde N° 060\tATWR\n" ,
                          
                          // "Cde N° 061\t+++\n" , "Cde N° 062\tATRE\n" , "Cde N° 063\tATID2468\n" , "Cde N° 064\tATCE1\n" , "Cde N° 065\tATCE1\n" , "Cde N° 066\tATSL\n" , "Cde N° 067\tATDH0013A200\n" , "Cde N° 068\tATDL4177E10A\n" , "Cde N° 069\tATAP0\n" , "Cde N° 070\tATWR\n" ,
                          // "Cde N° 071\t+++\n" , "Cde N° 072\tATRE\n" , "Cde N° 073\tATID2468\n" , "Cde N° 074\tATCE1\n" , "Cde N° 075\tATCE1\n" , "Cde N° 076\tATSL\n" , "Cde N° 077\tATDH0013A200\n" , "Cde N° 078\tATDL4177E10A\n" , "Cde N° 079\tATAP0\n" , "Cde N° 080\tATWR\n" ,
                          // "Cde N° 081\t+++\n" , "Cde N° 082\tATRE\n" , "Cde N° 083\tATID2468\n" , "Cde N° 084\tATCE1\n" , "Cde N° 085\tATCE1\n" , "Cde N° 086\tATSL\n" , "Cde N° 087\tATDH0013A200\n" , "Cde N° 088\tATDL4177E10A\n" , "Cde N° 089\tATAP0\n" , "Cde N° 090\tATWR\n" ,
                          // "Cde N° 091\t+++\n" , "Cde N° 092\tATRE\n" , "Cde N° 093\tATID2468\n" , "Cde N° 094\tATCE1\n" , "Cde N° 095\tATCE1\n" , "Cde N° 096\tATSL\n" , "Cde N° 097\tATDH0013A200\n" , "Cde N° 098\tATDL4177E10A\n" , "Cde N° 099\tATAP0\n" , "Cde N° 100\tATWR\n" ,
                          ""};
void setup()
{

  // *** Initialize Sérial Port
  Serial.begin(9600);

  // Wait the initialisation Ended
  delay( 2000 );


}
void loop() {

int Indice_String_Array = 0;

  // Wait the initialisation Ended
  delay( 2000 );

    // while a String Exist
    while( String_Array[ Indice_String_Array ] != "" )
    {

      // Output String ti Stdio
      Serial.print( String_Array[ Indice_String_Array++ ] );
      Serial.flush( );
      
      // Wait to Complete
      delay( 100 );
           
    }

    // Infinite wait
    while( 1 );
        
}

What are these "strange characters"? I don't see any in the output you posted.

Hello,

I expect to see "Cde N° 003\tATID2468\n" and the result is "Cde N° 003\tAT ▀2468\n"
visible on the joint file.

▀ is not my string.

Bests regards.

So, 100 61 Strings?

That's 600 366 bytes of RAM gone before you've even put any data in them.

The data then takes at least another 1200 bytes.

"Cde N° xxx" x 60 = 600 bytes completely wasted

So, out of your 2.5k bytes of RAM, you've wasted well over 1500, when ditching String and using PROGMEM would have solved your problem.