> Why doesn't the control enter the second while loop
Because the EOF you signalled to end the first loop hasn't gone away by the time you hit the second loop - so it will exit immediately because the stdin stream is still in the end of file state.
Perhaps something like
clearerr(stdin);
Or better, separate input from conversion, and get rid of all those horrid fflush() calls.
Code:
#include<stdio.h>
int main(void)
{
struct
{
int accno;
char tt; //!! you can't store a string here
float amt;
}x;
struct
{
int accno;
char name[30];
float bal;
}y;
char buff[BUFSIZ];
FILE *fa,*ft;
if((fa=fopen("acc.txt","wb+"))==NULL)
printf("Unable to open");
if((ft=fopen("trans.txt","wb+"))==NULL)
printf("Unable to open");
printf("Enter elements for acc.txt (accno, name, bal)\n");
while ( fgets( buff, sizeof(buff), stdin) != NULL ) {
if ( sscanf(buff,"%d %s %f",&y.accno,y.name,&y.bal)==3) {
fwrite(&y,sizeof(y),1,fa);
} else {
break;
}
}
printf("\nEnter contents for trans.txt(accno, tt, amt)\n");
while ( fgets( buff, sizeof(buff), stdin) != NULL ) {
if ( sscanf(buff,"%d %s %f",&x.accno,&x.tt,&x.amt) == 3 ) {
fwrite(&x,sizeof(x),1,ft);
} else {
}
}
fclose(fa);
fclose(ft);
return 0;
}