I have a code and I'm wondering what the difference between scanf() and to initialize an integer directly is. When I compile this code :
for(u=0;u<reihen;u++){                          
   fgets(a,MAX,stdin);
   k = strlen(a)-1;
   printf("Value of k: %d\n",k);
   for(z=0;z<k;z++){
   }
}
printf("hello");
}
with this initialization of "reihen"
scanf("%d",&reihen);
the code skips the fgets(a,MAX,stdin); and the rest of the code except for k = strlen(a)-1; and printf("Value of k: %d\n",k); but just for the first circuit. Then the code works fine.
and when I'm initialize the reihen directly like reihen = 2;
It doesn't skip anything.
Could someone explain me this please ?
 
    