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

    This is because in C, functions parameters are . In order for the scanf() function to modify the ' a ' variable in your main () function, the of ' a ' shall be given to scanf(), hence the usage of the …

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

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

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

  7. How to prevent scanf causing a buffer overflow in C?

    So snprintf writes some data to a string buffer, and sscanf reads from that created string. Where exactly does this replace scanf in that it reads from stdin?

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

  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 - Getting multiple values with scanf () - Stack Overflow

    I am using scanf() to get a set of ints from the user. But I would like the user to supply all 4 ints at once instead of 4 different promps. I know I can get one value by doing: scanf( "%i", &...