Click here to Skip to main content
15,903,362 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Visual C++ and C programming Pin
thierrypp18-Jan-06 9:58
thierrypp18-Jan-06 9:58 
GeneralRe: Visual C++ and C programming Pin
BadKarma18-Jan-06 10:07
BadKarma18-Jan-06 10:07 
GeneralRe: Visual C++ and C programming Pin
thierrypp18-Jan-06 10:20
thierrypp18-Jan-06 10:20 
GeneralRe: Visual C++ and C programming Pin
David Crow18-Jan-06 10:04
David Crow18-Jan-06 10:04 
GeneralRe: Visual C++ and C programming Pin
BadKarma18-Jan-06 10:17
BadKarma18-Jan-06 10:17 
GeneralRe: Visual C++ and C programming Pin
Graham Bradshaw18-Jan-06 12:15
Graham Bradshaw18-Jan-06 12:15 
GeneralRe: Visual C++ and C programming Pin
thierrypp18-Jan-06 12:34
thierrypp18-Jan-06 12:34 
GeneralRe: Visual C++ and C programming Pin
thierrypp18-Jan-06 12:43
thierrypp18-Jan-06 12:43 
a typical example, no *.h files

/* ---------------------- */
/* structure_en_globale.c */
/* ---------------------- */
#include <stdio.h>
#include <string.h>

/* -- declaration des constantes -- */
#define TAILLE_NOM 20
#define TAILLE_PRENOM 2*TAILLE_NOM
#define MAX_ETUDIANTS 50

struct etudiant {
char nom[TAILLE_NOM] ;
char prenom[TAILLE_PRENOM] ;
int age ;
} ;

/* -- variables globales -- */
int nbeleves=0 ;
struct etudiant tab_eleves[MAX_ETUDIANTS];

/* -- procedures et fonctions -- */
void saisie_eleves();
void affichage() ;
struct etudiant recherche_eleve(char nom_recherche[]);

/* ----------------------------------- */
main()
{
struct etudiant eleve ;
char nom_eleve[TAILLE_NOM] ;
int choix = -1 ;

/* -- boucle d'affichage du menu -- */
while (choix != 0 )
{
printf("\n");
printf(" -1- Saisie d'une liste d'Žlves \n");
printf(" -2- Recherche d'un Žlve \n");
printf(" -3- Affichage de la liste\n");
printf(" -0- FIN\n");
printf("\n");
printf("Choix:");
scanf("%d",&choix);

/* -- selecteur : appel des procedures -- */
switch (choix)
{
case 1 : saisie_eleves();
break ;

case 2 : printf("Entrez le nom de l'Žlve :");
scanf ("%s",nom_eleve);
eleve=recherche_eleve(nom_eleve);
if (! strcmp(eleve.nom,"NON_TROUVE"))
{
printf("Aucun %s trouvŽ\n",nom_eleve);
}
else
{
printf("Nom : %s\n",eleve.nom);
printf("PrŽnom : %s\n",eleve.prenom);
printf("Age : %d\n",eleve.age);
}
break ;

case 3 : affichage();
break ;

case 0 : printf("Au revoir \n");
break ;

default: printf("Erreur de saisie\n");
break;
}
}
}

/* ----------------------------------- */
void saisie_eleves()
{
struct etudiant studtmp ;
int termine ;

termine = 0 ;

/* -- boucle de saisie du tableau des eleves -- */
while (! termine)
{
printf("Entrez un nom (\"fin\" pour terminer):");
scanf("%s",studtmp.nom);

termine=((strcmp(studtmp.nom,"fin"))==0) ;

if (! termine)
{
printf("Entrez un prŽnom:");
scanf("%s",studtmp.prenom);

printf("Entrez un age:");
scanf("%d",&studtmp.age);

tab_eleves[nbeleves]=studtmp ;
nbeleves++ ;
}
}
}

/* ----------------------------------- */
struct etudiant recherche_eleve(char nom_recherche[])
{
struct etudiant studtmp, eleve_retour={"NON_TROUVE","",0};
int trouve, i ;

trouve = 0 ;
i = 0 ;

while ((! trouve) && (i < nbeleves) )
{
studtmp=tab_eleves[i++] ;
trouve=(!(strcmp(studtmp.nom,nom_recherche))) ;

if (trouve)
{
eleve_retour=studtmp ;
}
}
/* -- retourne une structure -- */
return eleve_retour ;
}

/* ----------------------------------- */
void affichage()
{
int i ;

printf("-- Liste des Žtudiants --\n");

for (i=0 ; i < nbeleves ; i++)
{
printf("%10s ",tab_eleves[i].nom);
printf("%10s ",tab_eleves[i].prenom);
printf("%4d\n", tab_eleves[i].age);
}
}
GeneralRe: Visual C++ and C programming Pin
thierrypp18-Jan-06 9:48
thierrypp18-Jan-06 9:48 
AnswerRe: Visual C++ and C programming Pin
Rage19-Jan-06 0:04
professionalRage19-Jan-06 0:04 
GeneralRe: Visual C++ and C programming Pin
thierrypp19-Jan-06 3:44
thierrypp19-Jan-06 3:44 
GeneralRe: Visual C++ and C programming Pin
Shraddhan22-Jan-06 19:22
Shraddhan22-Jan-06 19:22 
GeneralRe: Visual C++ and C programming Pin
Shraddhan22-Jan-06 19:28
Shraddhan22-Jan-06 19:28 
QuestionMFC GUI Pin
greendays_0118-Jan-06 7:36
greendays_0118-Jan-06 7:36 
AnswerRe: MFC GUI Pin
paragdoshi18-Jan-06 7:52
paragdoshi18-Jan-06 7:52 
AnswerRe: MFC GUI Pin
FarPointer18-Jan-06 8:01
FarPointer18-Jan-06 8:01 
GeneralRe: MFC GUI Pin
greendays_0118-Jan-06 8:18
greendays_0118-Jan-06 8:18 
GeneralRe: MFC GUI Pin
FarPointer18-Jan-06 8:38
FarPointer18-Jan-06 8:38 
AnswerRe: MFC GUI Pin
David Crow18-Jan-06 8:29
David Crow18-Jan-06 8:29 
GeneralRe: MFC GUI Pin
FarPointer18-Jan-06 8:49
FarPointer18-Jan-06 8:49 
GeneralRe: MFC GUI Pin
Owner drawn18-Jan-06 16:50
Owner drawn18-Jan-06 16:50 
QuestionViewer for installShield Express 2.2 Pin
jjmv18-Jan-06 7:23
jjmv18-Jan-06 7:23 
QuestionC++ to Assembly Pin
Tuotrut18-Jan-06 7:01
Tuotrut18-Jan-06 7:01 
AnswerRe: C++ to Assembly Pin
Maximilien18-Jan-06 7:24
Maximilien18-Jan-06 7:24 
AnswerRe: C++ to Assembly Pin
Rage18-Jan-06 7:33
professionalRage18-Jan-06 7:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.