sscanf with doubles

This is a discussion on sscanf with doubles within the C Programming forums, part of the General Programming Boards category; hi, im outputting doubles to a file so i can read them later for processing Code: double sentpacktime=0.0; double recvpacktime=0.0; ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    7

    sscanf with doubles

    hi, im outputting doubles to a file so i can read them later for processing

    Code:
    	double sentpacktime=0.0;
    	double recvpacktime=0.0;
    	printf("\nScanning: %s\n",fileOutBuf);
    	sscanf(fileOutBuf,"%d %f %f %d", &recvpackid, &sentpacktime, &recvpacktime, &packSize);
    	printf("%d %f %f %d\n\n", recvpackid, sentpacktime, recvpacktime, packSize);
    here's thr output i get:
    Code:
    Scanning: 14 1151496935.061920 1151496935.062168 1500
    14 0.000000 0.000000 1500
    why are the doubles not set properly? thanks

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    %f is for float
    %lf is for double

    Consult your local man page, or search engine, or search button, since I suspect this keeps getting asked...


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sscanf and string handling question
    By ursula in forum C Programming
    Replies: 14
    Last Post: 05-30-2009, 03:21 AM
  2. Problem using sscanf fgets and overflow checking
    By jou00jou in forum C Programming
    Replies: 5
    Last Post: 02-18-2008, 06:42 AM
  3. Problems reading formatted input with sscanf
    By Nazgulled in forum C Programming
    Replies: 17
    Last Post: 05-10-2006, 01:46 AM
  4. sscanf question
    By Zarkhalar in forum C++ Programming
    Replies: 6
    Last Post: 08-03-2004, 08:52 PM
  5. sscanf (I think)
    By RyeDunn in forum C Programming
    Replies: 7
    Last Post: 07-31-2002, 09:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21