This article is rated C-class on Misplaced Pages's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||
|
Untitled
And the usage? Do you have to press enter after setting the value? -212.149.219.87 14:57, 15 May 2007 (UTC)
- That should be answered here, as a property of unix stdin--190.31.123.176 (talk) 04:11, 31 July 2008 (UTC)
"Unlike scanf and fscanf, sscanf does not remove the read items away from the input flush. " -- What's an input flush? —Preceding unsigned comment added by 98.202.233.57 (talk) 08:31, 5 March 2009 (UTC)
Acceptance of negative values by %u
The text doesn't explain why (counter-intuitively) %u accepts a negative value to an unsigned integer. "−" being optional is irrelevant; if the input string doesn't contain "−", you have the normal case of specifying a non-negative integer. The article on strtoul() doesn't explain either, hence my tags. -- Regregex (talk) 15:37, 15 January 2011 (UTC)
This page so does not belong in Misplaced Pages
— Preceding unsigned comment added by 98.108.219.226 (talk • contribs) 18:27, 25 February 2010
- How do you know? ;) What should and what shouldn't ... it's a slippery slope; a wide grey line. .. but yeah. You're right :) Stevebroshar (talk) 09:32, 13 April 2024 (UTC)
scanf edge-cases
Does "%%" skip leading whitespace? That is, is it equivalent to " %%" or "%*1"? What is the way to match a character class equivalent to a single caret (not "^" but a potentially unlimited string of "^")? Something like "%" doesn't work because the character class isn't closed. 130.101.140.16 (talk) 17:04, 19 April 2011 (UTC)
scanf unsourced claim
The unsourced claim in section security does not work under gcc4.6 : the text implies that
scanf("Please enter a value %d",&n);
would output something like this while waiting for an integer
Please enter a value
However, the following code, compiled with gcc -Wall -Werror -ansi -pedantic
#include <stdio.h> int main(){ int d = 0; scanf("enter integer: %d", &d); printf("entered integer: %d\n", d); return 0; }
gives
$ ./a.out 10 entered integer: 0 $ ./a.out enter integer: 10 entered integer: 10
That is, you must enter 'enter integer ' before your actual input for it to work. Since the hypothesized behaviour does not seem to be widely implemented, i'm removing that claim (which also has nothing to do in the security section).
Je ne détiens pas la vérité universelle (talk) 22:28, 7 February 2012 (UTC)
This makes no sense
"As scanf is designated to read only from standard input, many programming languages with interfaces, such as PHP, have derivatives such as sscanf and fscanf but not scanf itself."
This has nothing to do with interfaces being present in the language or not. — Preceding unsigned comment added by 24.30.53.212 (talk) 17:10, 20 February 2012 (UTC)
Alternatives
A section mentioning functions such as atof(3), atoi(3), atol(3), strtod(3), strtoul(3) might be a good addition. — Preceding unsigned comment added by 75.154.106.91 (talk) 15:55, 13 January 2013 (UTC)
"%d" listed at Redirects for discussion
The redirect %d has been listed at redirects for discussion to determine whether its use and function meets the redirect guidelines. Readers of this page are welcome to comment on this redirect at Misplaced Pages:Redirects for discussion/Log/2024 March 17 § %d until a consensus is reached. Nickps (talk) 14:00, 18 March 2024 (UTC)
"Format string" listed at Redirects for discussion
The redirect Format string has been listed at redirects for discussion to determine whether its use and function meets the redirect guidelines. Readers of this page are welcome to comment on this redirect at Misplaced Pages:Redirects for discussion/Log/2024 March 18 § Format string until a consensus is reached. Nickps (talk) 14:00, 18 March 2024 (UTC)
Categories: