Re: conversion of types.



jj_76 wrote:
hello,
I have a data file with several columns consisting of double values. I
am reading the whole row as a string using fgets(). I want to convert
each column back into a double. It seems atof() converts only the first
column and strtod() also does the same. Is there any other way ?
thanks
------------
FILE *fp1;
char thing1[61];
double mtot;

fgets(thing1,61,fp1);
mtot = atof(thing1);


What is the actual format of the file? Are there a fixed number of columns (fields) per row? How are the fields delimited?

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
.



Relevant Pages

  • Re: conversion of types.
    ... am reading the whole row as a string using fgets(). ... strtod() and store the result in whatever way you want. ...
    (comp.lang.c)
  • Re: Question regarding fgets and new lines
    ... use fgets. ... "Reads characters from stream and stores them in string until ... It also includes more logical line reading functions like bgets which ...
    (comp.lang.c)
  • Re: Question regarding fgets and new lines
    ... "Reads characters from stream and stores them in string until ... use the same num as used in the fgets? ... it starts reading at the position where it left off the last time it was ...
    (comp.lang.c)
  • conversion of types.
    ... I have a data file with several columns consisting of double values. ... am reading the whole row as a string using fgets(). ... double mtot; ...
    (comp.lang.c)
  • Re: conversion of types.
    ... I have a data file with several columns consisting of double values. ... am reading the whole row as a string using fgets. ... It seems atof() converts only the first ... double mtot; ...
    (comp.lang.c)