Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > sscanf behaviou...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 9814 of 10094
Post > Topic >>

sscanf behaviour

by kimon.simons@[EMAIL PROTECTED] Jul 21, 2008 at 02:38 PM

In the following piece of code I get as result for f = 123457 instead
of 123456.78. Any ideas how this could have happened?

Thank you

#include <iostream>
using namespace std;

int main(int argc, char* argv[])
{
	double f;
	const char *test = "123456.78";
	sscanf(test, "%9lf", &f);
	cout<<f<<endl;
	return 0;
}

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 8 Posts in Topic:
sscanf behaviour
kimon.simons@[EMAIL PROTE  2008-07-21 14:38:05 
Re: sscanf behaviour
Oncaphillis <oncaphill  2008-07-21 23:12:37 
Re: sscanf behaviour
alasham.said@[EMAIL PROTE  2008-07-21 23:58:14 
Re: sscanf behaviour
Alberto Ganesh Barbati &l  2008-07-22 00:11:31 
Re: sscanf behaviour
Jack Klein <jackklein@  2008-07-22 00:13:55 
Re: sscanf behaviour
puzzlecracker <ironsel  2008-07-22 15:58:14 
Re: sscanf behaviour
cbarron413@[EMAIL PROTECT  2008-07-23 06:27:34 
Re: sscanf behaviour
Oncaphillis <oncaphill  2008-07-23 06:30:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 22:35:45 CDT 2008.