user57195: I am only replacing a portion of my code where I want to use the first method but as you can see it is making my sketch size little bigger
//if(iBPM >= 40 || iBPM <= 170 )
      {
      char iBPMwav[50];
      String thisString = String(iBPM);
      String stringThree =  "n" + thisString;
      stringThree =  stringThree + ".wav";
      stringThree.toCharArray(iBPMwav, 50); 
      tmrpcm.play(iBPMwav);   
      }

Sketch uses 29678 bytes (100%)
This is simple but at the end, I want to go from the number 40 up to 170, and this is why I want to use the first method.
//if(iBPM >= 40 || iBPM <= 170 )
  {
      if(iBPM == 71)
tmrpcm.play("n71.wav"); 
  else if(iBPM == 72)
tmrpcm.play("n72.wav");
  else if(iBPM == 73)
tmrpcm.play("n73.wav");  
  else if(iBPM == 74)
tmrpcm.play("n74.wav");     
  else if(iBPM == 75)
tmrpcm.play("n75.wav"); 
  else if(iBPM == 76)
tmrpcm.play("n76.wav"); 
  else if(iBPM == 77)
tmrpcm.play("n77.wav"); 
  else if(iBPM == 78)
tmrpcm.play("n78.wav"); 
  else if(iBPM == 79)
tmrpcm.play("n79.wav"); 
  else if(iBPM == 80)
tmrpcm.play("n80.wav"); 
  else if(iBPM == 81)
tmrpcm.play("n81.wav");
  else if(iBPM == 82)
tmrpcm.play("n82.wav");  
  else if(iBPM == 83)
tmrpcm.play("n83.wav");     
  else if(iBPM == 84)
tmrpcm.play("n84.wav"); 
  else if(iBPM == 85)
tmrpcm.play("n85.wav"); 
  else if(iBPM == 86)
tmrpcm.play("n86.wav"); 
  else if(iBPM == 87)
tmrpcm.play("n87.wav"); 
  else if(iBPM == 89)
tmrpcm.play("n89.wav");
  else if(iBPM == 90)
tmrpcm.play("n90.wav");
  else if(iBPM == 91)
tmrpcm.play("n91.wav"); 
  else if(iBPM == 92)
tmrpcm.play("n92.wav");
  else if(iBPM == 93)
tmrpcm.play("n93.wav");  
  else if(iBPM == 94)
tmrpcm.play("n94.wav");     
  else if(iBPM == 95)
tmrpcm.play("n95.wav"); 
  else if(iBPM == 96)
tmrpcm.play("n96.wav"); 
  else if(iBPM == 97)
tmrpcm.play("n97.wav"); 
  else if(iBPM == 98)
tmrpcm.play("n98.wav"); 
  else if(iBPM == 99)
tmrpcm.play("n99.wav");
  else if(iBPM == 100)
tmrpcm.play("n100.wav"); 
  else if(iBPM == 101)
tmrpcm.play("n101.wav"); 
  else if(iBPM == 102)
tmrpcm.play("n102.wav");                                                     
else 
 tmrpcm.play("n170.wav");
}

Sketch uses 29024 bytes (101%)

user20245: While the Strings class makes a C/C++ program easy to understand and maintain, as stated in the comments, using the Strings class is a memory intensive option which should be should be avoided when memory is in short supply.  Such as on the embedded processors used in most Arduino platforms.
Here are 2 examples where Stings is used and not used.  Note the reduction from 2326 bytes to 734 bytes of program memory necessary to store the sketch in the embedded processor.
void setup() 
{
}

void loop() 
{
  uint8_t iBPM;
  uint8_t pointer;
  for(iBPM = 40; iBPM <= 170; iBPM++)
  {
    char iBPMwav[50];
    String thisString = String(iBPM);
    String stringThree =  "n" + thisString;
    stringThree =  stringThree + ".wav";
    stringThree.toCharArray(iBPMwav, 50); 
//  tmrpcm.play(iBPMwav);   
  }
}

Sketch uses 2326 bytes (7%) of program storage space. Maximum is 32256 bytes. Global variables use 27 bytes (1%) of dynamic memory...
void setup() 
{
}

void loop() 
{
  uint8_t iBPM;
  uint8_t pointer;
  for(iBPM = 40; iBPM <= 170; iBPM++)
  {
    char iBPMwav[50];
    pointer = 0;
    char temp_str[10];
//  String thisString = String(iBPM);
//  String stringThree =  "n" + thisString;
//  stringThree =  stringThree + ".wav";
//  stringThree.toCharArray(iBPMwav, 50); 
    itoa(iBPM, temp_str, 10);
    if(iBPM < 100)
    {
      strncpy(&iBPMwav[pointer],"n0",2);
      pointer += 2;
      strncpy(&iBPMwav[pointer],temp_str,2);
      pointer += 2;
    }
    else
    {
      strncpy(&iBPMwav[pointer],"n",1);
      pointer += 1;
      strncpy(&iBPMwav[pointer],temp_str,3);
      pointer += 3;
    }
    strncpy(&iBPMwav[pointer],".wav",4);
//  tmrpcm.play(iBPMwav);   
  }
}

Sketch uses 734 bytes (2%) of program storage space. Maximum is 32256 bytes. Global variables use 15 bytes (0%) of dynamic memory...

user16780: I suggest having simpler file names (same size, always 3 digit numbers)
/// Return a text "n000.wav" ... "n255.wav" 
/// depending on the parameter 
char* makeFileName(byte i) {    
  static char name[9] = "nxxx.wav";
  byte digit = i/100;
  name[1] = '0' + digit;
  i -= digit*100; 
  digit = i/10;
  name[2] = '0' + digit; 
  i -= digit*10;
  name[3] = '0' + i;

  return name;
}


57195: <p>I am only replacing a portion of my code where I want to use the first method but as you can see it is making my sketch size little bigger</p>

<pre class="lang-c prettyprint-override"><code>//if(iBPM &gt;= 40 || iBPM &lt;= 170 )
      {
      char iBPMwav[50];
      String thisString = String(iBPM);
      String stringThree =  "n" + thisString;
      stringThree =  stringThree + ".wav";
      stringThree.toCharArray(iBPMwav, 50); 
      tmrpcm.play(iBPMwav);   
      }
</code></pre>

<p><strong><code>Sketch uses 29678 bytes (100%)</code></strong></p>

<p>This is simple but at the end, I want to go from the number 40 up to 170, and this is why I want to use the first method.</p>

<pre class="lang-c prettyprint-override"><code>//if(iBPM &gt;= 40 || iBPM &lt;= 170 )
  {
      if(iBPM == 71)
tmrpcm.play("n71.wav"); 
  else if(iBPM == 72)
tmrpcm.play("n72.wav");
  else if(iBPM == 73)
tmrpcm.play("n73.wav");  
  else if(iBPM == 74)
tmrpcm.play("n74.wav");     
  else if(iBPM == 75)
tmrpcm.play("n75.wav"); 
  else if(iBPM == 76)
tmrpcm.play("n76.wav"); 
  else if(iBPM == 77)
tmrpcm.play("n77.wav"); 
  else if(iBPM == 78)
tmrpcm.play("n78.wav"); 
  else if(iBPM == 79)
tmrpcm.play("n79.wav"); 
  else if(iBPM == 80)
tmrpcm.play("n80.wav"); 
  else if(iBPM == 81)
tmrpcm.play("n81.wav");
  else if(iBPM == 82)
tmrpcm.play("n82.wav");  
  else if(iBPM == 83)
tmrpcm.play("n83.wav");     
  else if(iBPM == 84)
tmrpcm.play("n84.wav"); 
  else if(iBPM == 85)
tmrpcm.play("n85.wav"); 
  else if(iBPM == 86)
tmrpcm.play("n86.wav"); 
  else if(iBPM == 87)
tmrpcm.play("n87.wav"); 
  else if(iBPM == 89)
tmrpcm.play("n89.wav");
  else if(iBPM == 90)
tmrpcm.play("n90.wav");
  else if(iBPM == 91)
tmrpcm.play("n91.wav"); 
  else if(iBPM == 92)
tmrpcm.play("n92.wav");
  else if(iBPM == 93)
tmrpcm.play("n93.wav");  
  else if(iBPM == 94)
tmrpcm.play("n94.wav");     
  else if(iBPM == 95)
tmrpcm.play("n95.wav"); 
  else if(iBPM == 96)
tmrpcm.play("n96.wav"); 
  else if(iBPM == 97)
tmrpcm.play("n97.wav"); 
  else if(iBPM == 98)
tmrpcm.play("n98.wav"); 
  else if(iBPM == 99)
tmrpcm.play("n99.wav");
  else if(iBPM == 100)
tmrpcm.play("n100.wav"); 
  else if(iBPM == 101)
tmrpcm.play("n101.wav"); 
  else if(iBPM == 102)
tmrpcm.play("n102.wav");                                                     
else 
 tmrpcm.play("n170.wav");
}
</code></pre>

<p><strong><code>Sketch uses 29024 bytes (101%)</code></strong></p>
 20245: <p>While the Strings class makes a C/C++ program easy to understand and maintain, as stated in the comments, using the Strings class is a memory intensive option which should be should be avoided when memory is in short supply.  Such as on the embedded processors used in most Arduino platforms.</p>

<p>Here are 2 examples where Stings is used and not used.  Note the reduction from 2326 bytes to 734 bytes of program memory necessary to store the sketch in the embedded processor.</p>

<pre><code>void setup() 
{
}

void loop() 
{
  uint8_t iBPM;
  uint8_t pointer;
  for(iBPM = 40; iBPM &lt;= 170; iBPM++)
  {
    char iBPMwav[50];
    String thisString = String(iBPM);
    String stringThree =  "n" + thisString;
    stringThree =  stringThree + ".wav";
    stringThree.toCharArray(iBPMwav, 50); 
//  tmrpcm.play(iBPMwav);   
  }
}
</code></pre>

<p>Sketch uses 2326 bytes (7%) of program storage space. Maximum is 32256 bytes. Global variables use 27 bytes (1%) of dynamic memory...</p>

<pre><code>void setup() 
{
}

void loop() 
{
  uint8_t iBPM;
  uint8_t pointer;
  for(iBPM = 40; iBPM &lt;= 170; iBPM++)
  {
    char iBPMwav[50];
    pointer = 0;
    char temp_str[10];
//  String thisString = String(iBPM);
//  String stringThree =  "n" + thisString;
//  stringThree =  stringThree + ".wav";
//  stringThree.toCharArray(iBPMwav, 50); 
    itoa(iBPM, temp_str, 10);
    if(iBPM &lt; 100)
    {
      strncpy(&amp;iBPMwav[pointer],"n0",2);
      pointer += 2;
      strncpy(&amp;iBPMwav[pointer],temp_str,2);
      pointer += 2;
    }
    else
    {
      strncpy(&amp;iBPMwav[pointer],"n",1);
      pointer += 1;
      strncpy(&amp;iBPMwav[pointer],temp_str,3);
      pointer += 3;
    }
    strncpy(&amp;iBPMwav[pointer],".wav",4);
//  tmrpcm.play(iBPMwav);   
  }
}
</code></pre>

<p>Sketch uses 734 bytes (2%) of program storage space. Maximum is 32256 bytes. Global variables use 15 bytes (0%) of dynamic memory...</p>
 16780: <p>I suggest having simpler file names (same size, always 3 digit numbers)</p>

<pre><code>/// Return a text "n000.wav" ... "n255.wav" 
/// depending on the parameter 
char* makeFileName(byte i) {    
  static char name[9] = "nxxx.wav";
  byte digit = i/100;
  name[1] = '0' + digit;
  i -= digit*100; 
  digit = i/10;
  name[2] = '0' + digit; 
  i -= digit*10;
  name[3] = '0' + i;

  return name;
}
</code></pre>
