0

i'm trying to read values from a txt file. the following code works well, but it only print the values to the standard output, i don't know how to store those values in a variable. Thankyou in advance.

char *value = NULL;
double Training[401], Test[50];
int i=0;
size_t line_buf_size = 0; 
while(i<4)
        {
            getline(&value, &line_buf_size, in_file);
            fscanf(in_file,"%s%*[^\n]",value);
            printf("value %s \n",value);
            Training[i]=(double)value; // error : pointer value used where a floating point value was expected
            //printf(" training %d i %d \n",Training[i], i);
            i++;
        }
ayloul
  • 31
  • 6

1 Answers1

0

I think the problem you are facing is storing your "value" variable (type: char *) into "Training[i]" (type: double).

You need to convert from char * to double: https://stackoverflow.com/a/10075336/7440867 .

David Rosu
  • 39
  • 4