Thread: sscanf with doubles

  1. #1
    Registered User
    Join Date
    Jun 2006

    sscanf with doubles

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

    	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:
    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
    %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...

    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, 02: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, 12:46 AM
  4. sscanf question
    By Zarkhalar in forum C++ Programming
    Replies: 6
    Last Post: 08-03-2004, 07:52 PM
  5. sscanf (I think)
    By RyeDunn in forum C Programming
    Replies: 7
    Last Post: 07-31-2002, 08:46 AM