About 64 results
Open links in new tab
  1. How does the scanf function work in C? - Stack Overflow

    The & in C is an operator that returns the address of the operand. Think of it this way, if you would simply give scanf the variable a without the &, it will be passed to it by-value, which means scanf will …

  2. c - What does the scanf function return? - Stack Overflow

    NAME scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf ... RETURN VALUE These functions return the number of input items successfully matched and assigned, which can be fewer than provided for, or …

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

    Dec 7, 2018 · So scanf("%*d %d", &i); would read two integers and put the second one in i. The value that was output in your code is just the value that was in the uninitialized i variable - the scanf call …

  4. How do I properly use scanf and what are its limits?

    Aug 3, 2025 · Thanks for asking. Here are some guidelines for using scanf within its limits. And here is a question abut alternatives to scanf.

  5. How to do scanf for single char in C - Stack Overflow

    Nov 24, 2012 · scanf(" %c", &c); The blank in the format string tells scanf to skip leading whitespace, and the first non-whitespace character will be read with the %c conversion specifier.

  6. scanf () leaves the newline character in the buffer

    The first scanf() doesn't return when a user has hit space, even though that's where the number ends (because at that point the line is still in the terminal's line buffer); and the second scanf() doesn't wait …

  7. How do you allow spaces to be entered using scanf?

    Aug 8, 2009 · Remember than scanf stands for "scan formatted" and there's precious little less formatted than user-entered data. It's ideal if you have total control of the input data format but generally …

  8. c - Using the scanf () function - Stack Overflow

    Apr 4, 2013 · Using scanf and printf when you're confused about types is dangerous! scanf ("%s", &userinput); The type of &userinput is char (*)[256], but scanf expects %s to correspond to a char *. …

  9. error C4996: 'scanf': This function or variable may be unsafe in c ...

    Jun 1, 2015 · The wikia link says scanf_s is " the same as scanf, except it is safe." Is there any reason why an implementation that can support scanf_s should have scanf not chain to the same function?

  10. c - Why does scanf require &? - Stack Overflow

    Oct 19, 2016 · I want to read a number from stdin. I don't understand why scanf requires the use of & before the name of my variable: int i; scanf("%d", &i); Why does scanf need the address …