Il faut que tu vérifies si (c % (LONGUEUR - 1) != 0)
if ((tabplace[c].Statut == LIBRE) && ((c + 1) < LONGUEUR * LARGEUR) \ && (tabplace[c+1].Statut == LIBRE)){
if(c % (LARGEUR - 1) != 0){au lieu de
if(c % (LONGUEUR - 1) != 0){
struct Client { char Nom[30]; char Prenom[30]; char Adresse[50]; char Mail[50]; char Telephone[15]; int IDClient; }; struct Client creerClient(struct Client tab_client[]){ struct Client C1; char nomClient[30]; char prenomClient[30]; char adresseClient[50]; char mailClient[50]; char telephoneClient[15]; int i; /************ Saisie des coordonnees du client ************/ printf("Client \n"); printf("Entrez votre nom :"); fgets(nomClient,30,stdin); printf("Entrez votre prenom : "); fgets(prenomClient,30,stdin); printf("Entrez votre adresse postale : "); fgets(adresseClient, 50, stdin); printf("Entrez votre mail : "); fgets(mailClient,50,stdin); printf("Entrez votre numero de telephone : "); scanf("%s", telephoneClient); printf("\n"); /************ Acces aux champs et initialisation des variables ************/ strcpy(C1.Nom,nomClient); strcpy(C1.Prenom,prenomClient); strcpy(C1.Adresse,adresseClient); strcpy(C1.Mail,mailClient); strcpy(C1.Telephone,telephoneClient); for (i = 0; i < MAX_NB_CLIENT; i++) { tab_client[i].IDClient = -1; /* par defaut tous les numeros de clients sont initialisés a -1 */ } C1.IDClient = 1; while(tab_client[i].IDClient < 0){ tab_client[i]= C1; tab_client[i].IDClient = i; i++; } return C1; } void afficherClient (struct Client tab_client[], int num){ struct Client C1; printf("********* FICHE CLIENT *********\n"); printf("*\n"); printf("* Nom : %s* Prenom : %s* Adresse : %s* Mail : %s* Telephone : %s \n", C1.Nom, C1.Prenom, C1.Adresse, C1.Mail, C1.Telephone); }
int main (){ struct Client tab_client[MAX_NB_CLIENT]; struct Client C1; int numClient; /* Creation d'un client */ case 1 : creerClient(tab_client); /* Affichage d'un client*/ case 2 : printf("Saisissez un num client a afficher ?"); scanf("%d", numClient); printf("\n\n"); afficherClient(tab_client, numClient);} }
/* Affichage d'un client*/, j'aimerais que l'ordi me demande quel numéro de client je souhaite afficher (s il existe) ?
Ligne environ 70: warning: unused parameter ‘tab_client’
Ligne environ 84: error: case label not within a switch statement
afficherClient(tab_client, numClient);}
gcc -W -Wall -ansi -pedantic fichier.c -o prog
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionint main() { /***** Declaration des variables *****/ int choix,fin=1; struct Place tabplace[LONGUEUR*LARGEUR]; struct Client tab_client[MAX_NB_CLIENT]; struct Client C1; int numClient; /*C1=creerClient(tab_client);afficherClient(C1);*/ while(fin){ /* creation du menu tant qu'on veut faire un choix */ printf("Que voulez-vous faire ? "); scanf("%d",&choix); printf("\n"); switch(choix){ case 4: { /* Affichage d'un client*/ printf("Saisissez un num client a afficher ?"); scanf("%d", numClient); printf("\n\n"); afficherClient(tab_client, numClient); printf("\n\n"); }break ; case 5: { /* Creation d'un client */ printf("\n"); viderTampon(); creerClient(tab_client); }break ; case 9: /* Sortir du programme */ printf("Fin du programme !\n\n"); exit(-1); break; default: printf(" Erreur : Ce choix n'est pas valide ! Faites un choix valide\n"); } } return 0; }
struct Place tabplace[LONGUEUR*LARGEUR];
scanf("%d", &numClient);
viderTampon()
viderTampon()est une fonction que j'ai crée pour effacer la mémoire tampon issue des scanf
void viderTampon() { char c; while((c = getchar() != '\n') && (c != EOF)); /* Permet de vider la memoire tampon */ }
Place tabplace[LONGUEUR*LARGEUR];c'est la définition de la salle de théatre que j'avais créee au tout debut mais la en fait je m'interesse juste aux clients. Quand je rentre les coordonnées de plusieurs clients les unes apres les autres et que je demande d'afficher celles d'un client en particulier , des symboles bizarres apparaissent dans les champs nom prenom etc