Pb boucle If ; langage C
Résolu/Fermé
pico07
-
24 oct. 2007 à 17:36
dubcek Messages postés 18587 Date d'inscription lundi 15 janvier 2007 Statut Contributeur Dernière intervention 12 mars 2023 - 25 oct. 2007 à 10:12
dubcek Messages postés 18587 Date d'inscription lundi 15 janvier 2007 Statut Contributeur Dernière intervention 12 mars 2023 - 25 oct. 2007 à 10:12
A voir également:
- Pb boucle If ; langage C
- D langage c ✓ - Forum C
- Langage ascii - Guide
- Pc s'allume et s'éteint en boucle - Forum Matériel informatique
- If exist ✓ - Forum Autoit / batch
- Et en langage c - Astuces et Solutions
4 réponses
Bonjour,
#include <stdio.h>
#include <string.h>
int main ()
{
char str_prenom[30];
char prenom_chef[30]="le prenom du chef\0";
printf ("entrez votre prenom : \n");
scanf ("%s" , str_prenom);
if (strcmp(str_prenom,prenom_chef)==0)
printf (" bonjour chef\n");
else
printf("bonjour mister\n");
return(0);
}
#include <stdio.h>
#include <string.h>
int main ()
{
char str_prenom[30];
char prenom_chef[30]="le prenom du chef\0";
printf ("entrez votre prenom : \n");
scanf ("%s" , str_prenom);
if (strcmp(str_prenom,prenom_chef)==0)
printf (" bonjour chef\n");
else
printf("bonjour mister\n");
return(0);
}
dubcek
Messages postés
18587
Date d'inscription
lundi 15 janvier 2007
Statut
Contributeur
Dernière intervention
12 mars 2023
5 583
25 oct. 2007 à 10:12
25 oct. 2007 à 10:12
if (str_prenom=le_prenom_du_chef)
attention à la différence enter = et == !!
attention à la différence enter = et == !!
ShaBoo
Messages postés
392
Date d'inscription
mercredi 12 septembre 2007
Statut
Membre
Dernière intervention
5 septembre 2009
50
24 oct. 2007 à 17:46
24 oct. 2007 à 17:46
Bonjour,
Essaye ceci :
Essaye ceci :
#include<stdio.h>
int main ()
{
char str_prenom[30];
printf ("entrez votre prenom : \n");
scanf ("%s" , str_prenom);
if (str_prenom==le_prenom_du_chef)
printf (" bonjour chef\n");
else
printf("bonjour mister\n");
return(0);
}