Top "Scanf" questions

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

Reading a string with scanf

I'm a little bit confused about something. I was under the impression that the correct way of reading a C …

c scanf
Reading string from input with space character?

I'm using Ubuntu and I'm also using Geany and CodeBlock as my IDE. What I'm trying to do is reading …

c string input scanf whitespace
How to do scanf for single char in C

In C: I'm trying to get char from the user with scanf and when I run it the program don't …

c char scanf
How do you allow spaces to be entered using scanf?

Using the following code: char *name = malloc(sizeof(char) + 256); printf("What is your name? "); scanf("%s", name); printf("Hello %s. …

c string printf scanf whitespace
Going through a text file line by line in C

I have been working on a small exercise for my CIS class and am very confused by the methods C …

c getline scanf
Why does scanf() need "%lf" for doubles, when printf() is okay with just "%f"?

Why is it that scanf() needs the l in "%lf" when reading a double, when printf() can use "%f" regardless …

c scanf length-modifiers
Reading in double values with scanf in c

I try to read-in 2 values using scanf() in C, but the values the system writes into memory are not equal …

c scanf conversion-specifier
What is the format specifier for unsigned short int?

I have the following program #include <stdio.h> int main(void) { unsigned short int length = 10; printf("Enter length : "); …

c scanf
How to read string from keyboard using C?

I want to read a string entered by the user. I don't know the length of the string. As there …

c string scanf
Reading numbers from a text file into an array in C

I'm a programming noob so please bear with me. I'm trying to read numbers from a text file into an …

c arrays file scanf