Hi
I've got a strange problem that i'm going to explain but before, here is my code:
/!\ This is not my finished application /!\
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <conio.h>
struct Date {
short Jour;
short Mois;
short Annee;
};
struct Ouvriers {
char Genre;
long NumRegistre;
char Nom[25];
char Prenom[30];
char Rue[50];
int CodePostal;
char Ville[20];
char Specialite[20];
struct Date DateNaiss;
struct Date DateEngag;
};
void AfficheOuvri(struct Ouvriers[], int);
int EncodeOuvri(struct Ouvriers[], int);
main ()
{
struct Ouvriers Personne[100];
int nOuvrier = 0;
int nFemme;
int nHomme;
int Out;
int Ret;
int i;
long NumReg[100];
int Index[100];
char Data[100][56];
do
{
nOuvrier = 0;
Out = 0;
Ret = EncodeOuvri(Personne, i);
if(Ret == 0)
{
Out = 1;
}
nOuvrier++;
}while(Out != 1);
system("cls");
for(i = 0; i < nOuvrier; i++)
{
AfficheOuvri(Personne, i);
}
}
int EncodeOuvri(struct Ouvriers Personne[], int i)
{
int Etat = 0;
printf("\n\nEncoder le genre: ");
fflush(stdin);
Personne->Genre=getchar();
if(Personne->Genre != '\n')
{
printf("\nEncoder le numero de registre: ");
fflush(stdin);
scanf("%d", &Personne->NumRegistre);
printf("\nEntrez votre nom: ");
fflush(stdin);
scanf("%s", &Personne->Nom);
printf("\nEntrez votre prenom: ");
fflush(stdin);
scanf("%s", &Personne->Prenom);
printf("\nNom de rue: ");
fflush(stdin);
scanf("%s", &Personne->Rue);
printf("\nCode postal: ");
fflush(stdin);
scanf("%d", &Personne->CodePostal);
printf("\nVille: ");
fflush(stdin);
scanf("%s", &Personne->Ville);
printf("\nSpecialite: ");
printf("\n\t1. Coffreur");
printf("\n\t2. Ferrailleur");
printf("\n\t3. Couvreur");
printf("\n\t4. Menuisier");
printf("\n\t5. Macon");
printf("\n\t6. Manoeuvre");
printf("\n\t7. Grutier\n");
printf("Votre choix: ");
fflush(stdin);
scanf("%d", &Personne->Specialite);
printf("\n\n\n");
Etat = 1;
}
return Etat;
}
void AfficheOuvri(struct Ouvriers Personne[], int i)
{
printf("\nGenre: %c", Personne->Genre);
printf("\nNumero de Registre: %d", Personne->NumRegistre);
printf("\nNom: %s", Personne->Nom);
printf("\nPrenom: %s", Personne->Prenom);
printf("\nRue: %s", Personne->Rue);
printf("\nCode postal: %d", Personne->CodePostal);
printf("\nVille: %s", Personne->Ville);
}
So I explain a little bit because it's in french.
I've go to make a programm for a work construction.
I've got to register worker and then printf them, and here is my problem.
Register worker is okey but when i've got printf them there is a little bug:
Gender(Genre) has always nothing to prinft, i've tried with getchar scanf and no matter...
Sorry for my bad english. :)