Si può anche pensare di fare una cosa del tipo:
codice:
#define LANG_ITALIANO 0
#define LANG_ENGLISH 1
typedef struct
{
char *aspetta;
char *premi_un_tasto;
} STR_LANG;
STR_LANG strLang[2] =
{
{
"Aspetta",
"Premi un tasto"
},
{
"Wait",
"Press a key"
}
};
Quando l'utente ha scelto italiano o inglese, basta impostare una variabile (es. idxLang) a 0 oppure 1. A quel punto basta prendere strLang[idxLang].aspetta per avere la stringa. E così per tutte le altre.
EDIT: C'è anche un'altra possibilita: invece di usare un array, usare un puntatore.
codice:
typedef struct
{
char *aspetta;
char *premi_un_tasto;
} STR_LANG;
STR_LANG strLang_Italiano =
{
"Aspetta",
"Premi un tasto"
};
STR_LANG strLang_English =
{
"Wait",
"Press a key"
};
STR_LANG *strLang;
Quando l'utente sceglie la lingua fai:
strLang = &strLang_Italiano;
oppure
strLang = &strLang_English;
e poi usi sempre strLang->aspetta per accedere alla stringa.
Scegli quella che ti piace di più.