home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / question / 9644 < prev    next >
Encoding:
Text File  |  1992-07-31  |  985 b   |  32 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!princeton!newross!samadams!tr
  3. From: tr@samadams.princeton.edu (Tom Reingold)
  4. Subject: Re: Using sed to convert numbers (interesting)
  5. Message-ID: <tr.712606300@samadams>
  6. Sender: news@newross.Princeton.EDU (USENET News System)
  7. Organization: Noo Joizy, USA
  8. References: <1992Jul31.121118.27783@news.acns.nwu.edu>
  9. Date: 31 Jul 92 18:11:40 GMT
  10. Lines: 20
  11.  
  12. Without addressing your questions about sed, why not use a simple
  13. little C program, since scanf or sscanf will do what you want?
  14.  
  15. #include <stdio.h>
  16.  
  17. main()
  18. {
  19.         char line[80];
  20.         float f;
  21.  
  22.         while (gets(line) != NULL) {
  23.                 sscanf(line, "%f", &f);
  24.                 printf("%f\n", f);
  25.         }
  26. }
  27. --
  28.         Tom Reingold
  29.         tr@samadams.princeton.edu  OR  ...!princeton!samadams!tr
  30.         "Warning: Do not drive with Auto-Shade in place.  Remove
  31.         from windshield before starting ignition."
  32.