1) suggest you define macros STDIN and STDOU instead of hardcoding 0 and 1 in the read/write statements
#define STDOUT 1 #define STDIN 0
2) use sizeof operator to get the size of data
write( STDOUT, buf4, strlen(buf4) ); read( STDIN, myArr[i].gender, sizeof(myArr[i].gender) ); write( STDOUT, buf5, strlen(buf5) ); read( STDIN, myArr[i].status, sizeof(myArr[i].status) );
[edit] And what they said above ^^^^ [/edit]
Hi,
Please consider the following example code
char a, c;
scanf("%c", &c);
scanf("%c", &a);
//printf("[c:%c, a:%c]\n", c, a);
when we run it the second scanf() statement takes the '\n' that is entered while entering a character for the first scanf().
It may be because the input buffer is not reset after the first scanf().
But I tried doing an fflush(stdin) before the second scanf() and it still doesn't take the second input.
Can u put some light on this issue.
Thanks in advance