Hi there, I am having trivial problem in reading a simple file (see below).
This file is not a list of numbers or list of strings, but is a combination of the two.
All is fine when I read it line by line and assign the numbers to a certain variable by using fscanf, but when I try to do the same for the strings, I obtain a bus error.
I hope someone can help;
thank you in advanced,
My code looks as it follows, and the input file is the next:
Code to read it:Code:problem_type problem_name 24.5 53.1 44.0
Code:FILE *file_ID; const char *problem; // After reading the file this variable would be something like this: // problem = "problem_type" // problem = "problem_name" int i,j,k=0; float, x,y,z; file_ID = fopen("input.txt", "r"); //Read the content of the input file: fgets(problem,..4,..file_ID); fgets(problem,..4,..file_ID); fscanf(file_ID, "%f\n", &x); fscanf(file_ID, "%f\n", &y); fscanf(file_ID, "%f\n", &z);