This is the mail archive of the cygwin mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi to all, I'm running Cygwin 1.5.13 under Windows XP Pro and have noticed the following problem with sscanf. If I ask it to parse the strings "n" and "na" using "%lf%n" it returns the value 0.0, and also reports the lengths as 1 and 2 respectively. The following program shows the problem: #include <stdio.h> int main( int argc, char *argv[] ) { char *strs[] = { "n", "na", "nan", "b" }; double num; int len; int i; for ( i = 0; i < 4; i++ ) { num = 1.1111; len = 0; printf( "str is '%s' \n", strs[i] ); sscanf( strs[i], "%lf%n", &num, &len ); printf( "num is %g \n", num ); printf( "len is %d \n\n", len ); } } With output: str is 'n' num is 0 len is 1 str is 'na' num is 0 len is 2 str is 'nan' num is NaN len is 3 str is 'b' num is 1.1111 len is 0 Clearly num and len should be returned as 1.1111 and 0. I included "nan" as I suspect the root of the problem is caused by its similarity. Cheers, Peter.
Attachment:
cygcheck.out
Description: Text document
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |