scanf() and gets() used together

Deal all,

i read a book and it told me not to use the two i/o functions together.Here is a

little demo shows why.

first of all,the input file is

ABCDEFG
bbbbXXXX //b stands for space ,this comment is not included in the file

1
2
3
4
5
6
7
char input[100],ch[100]; 
void main(void) 
{ 
    freopen("input.txt","r",stdin); 
    scanf("%s\n",&input); 
    gets(ch);   
} 

guess what is the value of ch ? Is it bbbbXXXX or XXXX? Believe it or not,it is
XXXX with no spaces preceded, Obviously,spaces are skipped in the input buffer.
so,can anybody explain the implementation of the scanf ?

Thanks for any solutions or pointers !
Last edited on
Topic archived. No new replies allowed.