I am learning C with Deitel's and Deitel's C programming book. Most of the times, when they use the scanf fucntion, for a char name[20];, they usually write: scanf("%19s", name);, in order to avoid buffer overflow.
But what can we do if the length of the array is a symbolic constant, say #define LENGTH 20. Obviously, using scanf("%LENGTHs, name); or even scanf("%"LENGTH"s", name); doesn't really help.
My problem also applies to the fscanf function, when we have to do with a stream different than stdin.
fgets()and avoid usingscanf().scanf()does input and parsing and is inadequate for both tasks.