Preprocessor and Format String Substitution
3 answers
In your code, the problem is in
scanf("%SIZEs", s);
Anything between the quotes of the " "
format string (string literal, in general) will not be replaced by the MACRO replacement.
So yours scanf()
stays the same as you, after preprocessing and %S
(or, %SIZEs
in general) being one invalid format specifier, you end up in undefined and hence got an error.
You can try a workaround like
scanf("%"SIZE"s", s);
So it SIZE
will be outside the quotes and will be considered for replacement in the preprocessing stage.
+2
source to share