Something like this, maybe?
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
const char filename[] = "test.txt";
FILE *file = fopen(filename, "r");
if ( file != NULL )
{
size_t i, count, size = 10;
double *x = malloc(size * sizeof(*x));
double *y = malloc(size * sizeof(*y));
double *z = malloc(size * sizeof(*z));
if ( x != NULL && y != NULL && z != NULL )
{
/* Read all three columns. */
for ( count = 0; count < size; ++count )
{
if ( fscanf (file ,"%lf%lf%lf", &x[count], &y[count], &z[count]) != 3 )
{
break;
}
}
/* Use only the first two columns. */
for ( i = 0; i < count; ++i )
{
printf("x = %f, y = %f\n", x[i], y[i]);
}
free(x);
free(y);
free(z);
}
}
return 0;
}
[edit]
Oops! I had to fix the code to take my own advice! (I previously had %lf in the printf.)
[/edit]