About 12,300,000 results
Open links in new tab
  1. 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 …

  2. 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.

  3. 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 …

  4. 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.

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

    10 From scanf: On success, the function returns the number of items successfully read. This count can match the expected number of readings or fewer, even zero, if a matching failure happens. In the …

  6. Read a string as an input using scanf - Stack Overflow

    Jan 30, 2016 · char str[25]; And you cannot use scanf to read sentences--it stops reading at the first whitespace, so use fgets to read the sentence instead. And in your last printf, you need the %c …

  7. 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 …

  8. Is there a way to use scanf with the "if" and "else" statements?

    May 22, 2013 · I have to create and call a function from main. Then I have to call scanf to read two integers and print out the bigger one. Then I have to do another scanf, but this time with doubles …

  9. C - scanf () vs gets () vs fgets () - Stack Overflow

    Jul 10, 2015 · Third, when using scanf() function, the result is completely wrong because first character apparently has a -52 ASCII value. For this, I have no explanation. Now I know that gets() is …

  10. What does `scanf ("%* [^\n]%*c")` mean? - Stack Overflow

    May 6, 2015 · scanf("%*[^\n]"); scanf("%*c"); to clear the stdin. This is because, in the former case (single scanf), %*[^\n] will fail when the first character to be scanned is the \n character and the rest …