Top "Scanf" questions

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

scanf: "%[^\n]" skips the 2nd input but " %[^\n]" does not. why?

Consider the following code: #include <stdio.h> int main (void) { char str1[128], str2[128], str3[128]; printf ("\nEnter str1: "); scanf ("%[^\…

c scanf
scanf() leaves the new line char in the buffer

I have the following program: int main(int argc, char *argv[]) { int a, b; char c1, c2; printf("Enter something: "); …

c scanf
What is the simplest way of getting user input in C?

There seem to be a LOT of ways you can get user input in C. What is the easiest way …

c input io scanf
Difference between scanf and scanf_s

What is the difference between scanf and scanf_s? In the university I have been taught and I am using …

c visual-studio scanf tr24731
what is the Java equivalent of sscanf for parsing values from a string using a known pattern?

So I come from a C background (originally originally, though I haven't used that language for almost 5 years) and I'm …

java scanf
What are scanf("%*s") and scanf("%*d") format identifiers?

What is the practical use of the formats "%*" in scanf(). If this format exists, there has to be some purpose …

c formatting scanf
Format specifiers for uint8_t, uint16_t, ...?

If I have an integer variable I can use sscanf as shown below by using the format specifier %d. sscanf (…

c++ c++11 scanf
using scanf function with pointers to character

I have written the following piece of code. int main(){ char arrays[12]; char *pointers; scanf("%s",arrays); scanf("%s",pointers); …

c scanf
How to skip a line when fscanning a text file?

I want to scan a file and skip a line of text before reading. I tried: fscanf(pointer,"\n",&(*…

c file scanf
What's the difference between gets and scanf?

If the code is scanf("%s\n",message) vs gets(message) what's the difference?It seems that both of them …

c input scanf gets