Question

Je fais un programme Win32 avec C et je ne sais pas comment faire un étui d'enum et de commutation avec Unicode. Je reçois du client un tuyau nommé avec cette structure

    typedef struct {
TCHAR UtilOrigem[10];
TCHAR Comando[3]; // Comando
TCHAR Argumento1[10];
}cmd;

cmd.comando a des valeurs "00", "01", "02" .....

Et je veux faire un étui de commutation avec cmd.comando.

aidez-moi s'il vous plaît. Merci Carlos

Était-ce utile?

La solution

Essayez ceci:

int val = _ttoi(cmd.comando);
switch (val)
{
case 0:
   ...
   break;
case 1:
   ...
   break;
case 2:
   ...
   break;
...
}

ou même plus simple:

int val = 10*(cmd.comando[0]-L'0')+(cmd.comando[1]-L'0');
switch (val)
{
case 0:
   ...
   break;
case 1:
   ...
   break;
case 2:
   ...
   break;
...
}

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top