I need to get data form single line in my data file. I'm finding the right line, but i read all values as 0, no matter what it suppost to be.
The start
Code:
int main(void)
{
file = fopen("data.csv", "r");
printf("Enter the name of the currency wanted.\n");
scanf("%s",&countryw);
find_a_line();
printf("%.2lf\n\n\n",&find_a_line);
fclose(file);
while( '\n' != getchar());
getchar();
return(0);
}
Finding and reading a specific line
Code:
double find_a_line(void)
{
lines = 1;
for(i=0; i < lines; i++)
{
fscanf(file, "%s %lf", &country, &valuta);
if(strcmpi(countryw,country) != 0)
{
lines ++;
}
}
return valuta;
}
the data.csv file contains
Code:
EUR 0.130000
USD 0.180000
GBP 0.110000
can someone figuer out why is read all values as 0.00?