Top "Scanf" questions

Questions related to the scanf() family of functions in the C runtime library, which read and convert formatted data.

Specifying the maximum string length to scanf dynamically in C (like "%*s" in printf)

I can specify the maximum amount of characters for scanf to read to a buffer using this technique: char buffer[64]; /* …

c io size buffer scanf
What is the effect of trailing white space in a scanf() format string?

What is difference between scanf("%d") and scanf("%d ") in this code, where the difference is the trailing blank in …

c scanf
Does fscanf moves the passed file pointer ahead?

I saw this code somewhere: #include<stdio.h> int main() { FILE * fp; char s[1024]; fp = fopen("file","r"); …

c file-io scanf file-pointer
Why does scanf() need & operator (address-of) in some cases, and not others?

Why do we need to put a & operator in scanf() for storing values in an integer array but not …

c arrays scanf ampersand
C++ alternative for parsing input with sscanf

Assuming my program expects arguments of the form [ 0.562 , 1.4e-2 ] (i.e. pairs of floats), how should I parse this input …

c++ parsing scanf
What can I use for input conversion instead of scanf?

I have very frequently seen people discouraging others from using scanf and saying that there are better alternatives. However, all …

c scanf
Why does scanf require &?

I want to read a number from stdin. I don't understand why scanf requires the use of & before the …

c scanf
undefined reference to `scanf_s'

I've got a piece of coursework to get done quickly which requires me to be able to debug the code …

c scanf c11 tr24731
Difference between fgets and gets

What is the difference between fgets() and gets()? I am trying break my loop when the user hits just "enter". …

c scanf fgets gets
scanf() variable length specifier

How can I use a variable to specify the max number of chars scanf() should read in? For example using …

c scanf