I'm often using C code to take some input and manipulate it; for example, I want to scan a full phrase like "hello world" but as it contains a space, I find myself forced to use "gets" to include the spaces or even tabs sometimes.
Asked
Active
Viewed 70 times
0
-
2[You cannot use `gets()` safely](https://stackoverflow.com/q/1694036/15168) — you should never, ever use it. That question highlights alternatives. Do you want to read lines, or do you have some other form of input in mind? – Jonathan Leffler Jan 26 '22 at 20:55
-
2@Kami SM Instead use fgets. – Vlad from Moscow Jan 26 '22 at 20:56
-
1You can use `sscanf` to parse the string after reading it in with `fgets`. Is that what you are after? – kaylum Jan 26 '22 at 21:12
1 Answers
0
you cant use scanf()
or fgets
, just remember use the stdin
as input stream

DolevA
- 16
- 1
-
1Do you mean one *can* use those functions? In that case, a little more detail would be warranted, especially for `scanf()`. As far as `stdin` being an available stream, did you then mean that one can use *`fscanf()`*? – John Bollinger Jan 26 '22 at 21:28