Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- struct infoski infoski ;
- struct infoski
- {
- char *nom;
- char *adresse;
- int psk;
- };
- void afficher_vec(struct infoski *skieur)
- {
- int i;
- printf("\t***************les skieurs reserves**********\n");
- printf("\t+--------------------------------------------\t\n");
- printf("\t NOM | ADRESSE | PSK \n");
- printf("\t+--------------------------------------------\t\n");
- for(i=0;i<25;i++)
- {
- printf("\t %s | %s | %d \n",skieur[i].nom,skieur[i].adresse,skieur[i].psk);
- printf("\t+-------------------------------------------\n");
- }
- }
- int cherchskieur(struct infoski *skieur,char *mot)
- {
- int i=0;
- while((skieur[i].nom)!=NULL)
- {
- if(strcmp(skieur[i].nom,mot)==0)
- {
- return(i);
- }
- else
- {
- i++;
- }
- }
- return(-1);
- }
- int main()
- {
- struct infoski *skieur ;
- char *name=NULL;
- skieur=malloc(25 * sizeof(struct infoski));
- printf("NOM: ");
- scanf("%s",skieur[2].nom);
- printf("ADRESSE: ");
- scanf("%s",skieur[2].adresse);
- printf("PSK: ");
- scanf("%d",&skieur[2].psk);
- afficher_vec(skieur);
- printf("enter le nom du skieur que vous cherchez");
- scanf("%s",name);
- if (cherchskieur(skieur,name)!=-1)
- {
- printf("l'indice de skieur est: %d",cherchskieur(skieur,name) );
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement