getchar() doesn’t execute itself while storing character in a struct variable’s member [duplicate]

Solution for getchar() doesn’t execute itself while storing character in a struct variable’s member [duplicate]
is Given Below:

I’m trying to store characters in a struct variable’s member which is an array, using getchar function. The problem is getchar() doesn’t execute itself, although my algorithm seems to be right. If I try to use getchar at the beginning of the programm it works but when I’m using it inside the: if (input.pin==client[c].pin) at the very end of the programm, getchar doesn’t execute itself. why?

typedef struct compte {


int pin;
char nom[10];
char prenom[10];
char ddn[11];
char adresse[40];
float solde;

}compte;




int main()
{


compte client[4]={
                  {3625,"Harris", "Donald","26/08/1987","62 rue Calmette", 35700.00 },
                  {4512,"Anderson","Pamela","21/01/1966","5 rue Charles le Chauve", 68400.66},
                  {9912,"Barry","Sylvia","03/04/1971","8 rue Courtine",130755.65},
                  {7164,"Cardec","Jonas","04/05/1941","51 rue de la vielle table",575441.41}

                 };
compte input;

int c=0;
int c2=0;
int L;
int i=0;




printf("BIENVENU A LA SOCIETE GENERALE");




printf("nCode pin sur 4 chiffres: ");
scanf("%d", &input.pin);



 while ( input.pin != client[c].pin )
  {
    c++;

     if (c==4)
    {
        c=0;
        c2++;
        printf("nCode pin introuvable.nReessayez: ");
        scanf("%d",&input.pin);
    }

      while (c2==2 && input.pin != client[c].pin  )
      {
        c++;

        if(c==4)
        {
        printf("nnCode pin introuvable. Reprenez votre carte.n");
        break;
        }
      }
  }




if (input.pin==client[c].pin)
 {

     printf("nnEntrez votre nom, prenom, date de naissance et adresse.nn");



     printf("NOM: ");
     scanf("%s", input.nom);

     
     printf("PRENOM: ");
     scanf("%s", input.prenom);

     
     printf("DATE DE NAISSANCE AU FORMAT 00/00/0000: ");
     scanf("%s", input.ddn);

     while( input.ddn[2] != "https://codeutlity.org/"  &&    input.ddn[5] !=  "https://codeutlity.org/" )
     {
         printf("nVotre date de naissance doit être au format 00/00/0000.");
         printf("nEntrez votre date de naissance au format 00/00/0000: ");
         scanf("%s", input.ddn);
     }

     
     printf("ADRESSE: ");
     while((L=getchar())!= 'n')
     {
         if (i<5)
         {
             input.adresse[i]=L;
             i++;
         }
     }
     input.adresse[i]='';


 }



    return 0;
}

Before printf("ADRESSE: ");, I would use one more getchar() to consume trailing whitespace left from one of prior scanfs.

Try the following:

     printf("ADRESSE: ");
     short flag = 0;
     while(flag == 0) {
         L = getchar();
         if(L != 'n')
            flag = 1;
         if(flag == 1 && i < 5)
         {
            input.adresse[i]=L;
            i++;
         }
     }

It has to do with using getchar() to assign L in the while comparison. Put the flag declaration with the rest of your variables