use fgets or fread

It’s better to use a field specifier, or a combination of fgets and sscanf, to read in a line of input and scan it. This will prevent possible buffer overflows that could be exploited by a malicious user.
-- Begining Linux Programming 115 Chapter 3


Try to use other functions, like fread or fgets, to read input lines and the string functions to break the input into the items you need.
-- Begining Linux Programming 116 Chapter 3

你可能感兴趣的:(read)