# String Concatenation

This example copies some strings stored in Program memory into a global array.
After each string is copied it is added to a buffer using strcat.
Finally the resulting string is converted to all upper case using strupr.

## Processor: ATtiny 2313

This example was compiled for the 2313 and may give incorrect results on other processors.*\
The calculation takes 3520 cycles and uses the following C code:

```
#include <avr/pgmspace.h>
#include <string.h>

char string_1[] PROGMEM = "The quick";
char string_2[] PROGMEM = "brown fox";
char string_3[] PROGMEM = "jumped over";
char string_4[] PROGMEM = "the lazy";
char string_5[] PROGMEM = "dog";

PGM_P string_table[] PROGMEM = {
  string_1,
  string_2,
  string_3,
  string_4,
  string_5
};

char sentence[70];

int main(){
  char buffer[12];

  for (unsigned char i = 0; i < 5; i++){
    strcpy_P(buffer,(PGM_P)pgm_read_word(&(string_table[i])));
    strcat(sentence,buffer);
    if(i < 4)
      strcat(sentence," ");
  }
  strcat(sentence,".");
  strupr(sentence);
  
  return 0;
}
```

The resulting string is stored in ram starting at location 0x60. The result can best be seen by looking in the 'abc' column of the memory panel.
##### *_For example, if  run on the ATmega238, the result of the calculation is in the I/O memory rather than sram. Values in I/O memory may be masked._
