J
JJ
I've just been studying C. I have some outdated experience with
Pascal and Fortran which might be throwing me off.
From the Deitel book I've been reading, it seems I have these three
options for stdin input:
getchar()
scanf
gets
getchar is tedious because I have to do a character by character loop.
scanf stops at the first space, so if I try to input a sentence, this
is no good.
when I try to use gets my compiler tells me it is dangerous to use.
(1) why is gets dangerous
(2) what is the proper way to input one whole line of text?
Thanks.
Pascal and Fortran which might be throwing me off.
From the Deitel book I've been reading, it seems I have these three
options for stdin input:
getchar()
scanf
gets
getchar is tedious because I have to do a character by character loop.
scanf stops at the first space, so if I try to input a sentence, this
is no good.
when I try to use gets my compiler tells me it is dangerous to use.
(1) why is gets dangerous
(2) what is the proper way to input one whole line of text?
Thanks.