Originally Posted by
dodzy
Yes that was a problem with the early version of the .txt file that I have posted here, however, this has been rectified thanks to a boring morning spent separating these values.
This should no longer be a problem!
Posting the current file would allow me and others to continue playing along. I was working with this (I renamed your file for my testing).
Code:
#include <stdio.h>
int main()
{
static const char filename[] = "mass.txt";
FILE *file = fopen(filename, "r");
if ( file != NULL )
{
char line[BUFSIZ];
while ( fgets(line, sizeof line, file) != NULL )
{
int a, b;
double c, d, e, f;
if ( sscanf(line, "%3d%3d%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) == 6 )
{
printf("%3d %3d %10.3f %8.3f %11.3f %8.3f\n", a, b, c, d, e, f);
}
}
fclose(file);
}
else
{
perror(filename);
}
return 0;
}