How to use strcpy?

How can i use strcpy (if available in arduboy librares), to copy a string?
I want to copy the string to a char variable. Or theres another way to do it?
This is the function im using:

void resolucion() {
int opcion;
const char *titulo = “Resolucion”;
const char *opciones [] = {“HD”, “2K”, “3.2K”, “4K”, “5K”, “6K”, “8K”};
int n = 7;
opcion = menu(titulo, opciones, n);

switch(opcion) {
case 8:
strcpy(res, opciones[0]);
break;

case 16:
strcpy(res, opciones[1]);
break;

case 24:
strcpy(res, opciones[2]);
break;

case 32:
strcpy(res, opciones[3]);
break;

case 40:
strcpy(res, opciones[4]);
break;

case 48:
strcpy(res, opciones[5]);
break;

case 56:
strcpy(res, opciones[6]);
break;
} 

}

The thing is that i want at the end to print res.
Thanks

I lifted this bit of code from Dark and Under. It looks suspiciously like @Pharap’s. It stores the strings in PROGMEM (not RAM) and returns them into a local variable read for printing …

      const __FlashStringHelper * text = nullptr;

      switch (itemType) {

        case ItemType::Key:
          text = F("SOME KEYS");
          break;

        case ItemType::Potion:
          text = F("HP POTION");
          break;

        case ItemType::Scroll:
          text = F("A SCROLL");
          break;

        case ItemType::Shield:
          text = F("A SHIELD");
          break;

        case ItemType::Sword:
          text = F(" A SWORD");
          break;

        default: break;

    }
1 Like

Do you really need a copy?

Is there a reason you can’t just use a const char *?

If you told us the underlying problem then we might be able to suggest a better solution.