Switch case
Résolu
nadhem09
Messages postés
7
Statut
Membre
-
nadhem09 Messages postés 7 Statut Membre -
nadhem09 Messages postés 7 Statut Membre -
Bonjour,
ceci mon code avec une swiitch case autonome .
il ne fonctionne pas . il reste toujours dans la premiere (case 0)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void control (void) {
static char step =0;
switch(step) {
case 0 :
printf("im in 0");
step = 1 ;
printf("%d",step);
break ;
case 1 :
printf("%d",step);
printf("im in 1");
step = 2 ;
break ;
case 2 :
printf("im in 2");
break ;
}
}
int main(void) {
control();
}
je besoins de l'aide s'il vous plais
ceci mon code avec une swiitch case autonome .
il ne fonctionne pas . il reste toujours dans la premiere (case 0)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void control (void) {
static char step =0;
switch(step) {
case 0 :
printf("im in 0");
step = 1 ;
printf("%d",step);
break ;
case 1 :
printf("%d",step);
printf("im in 1");
step = 2 ;
break ;
case 2 :
printf("im in 2");
break ;
}
}
int main(void) {
control();
}
je besoins de l'aide s'il vous plais
A voir également:
- Switch case
- Android switch - Accueil - Android
- Smart switch pc - Télécharger - Divers Bureautique
- Switch off - Télécharger - Divers Utilitaires
- Logiciel switch - Télécharger - Conversion & Extraction
- Switch 2 - Accueil - Jeu vidéo
3 réponses
Bonjour,
Ben oui,
on appelle control()
step = 0
on switch sur step, donc on va dans case = 0
dedans, on met step à 1
on imprime step
on break, donc on sort du switch
on sort de control()
on termine le programme
Ben oui,
on appelle control()
step = 0
on switch sur step, donc on va dans case = 0
dedans, on met step à 1
on imprime step
on break, donc on sort du switch
on sort de control()
on termine le programme
Avec les balises de code:
#include <stdio.h> #include <stdlib.h> #include <string.h> void control (void) { static char step =0; switch(step) { case 0 : printf("im in 0"); step = 1 ; printf("%d",step); break ; case 1 : printf("%d",step); printf("im in 1"); step = 2 ; break ; case 2 : printf("im in 2"); break ; } } int main(void) { control(); return(0); }
mais ca marche maintenant mercciii