Method 1 requires a file (impossible on stdin)... so you basically do: (untested code)

Code:
for (rows = 0; fscanf(in, "%f", &f) == 1; rows++)
  ;
rewind(in);
x = malloc(rows * sizeof(float));
for (i = 0; i < rows; i++)
    fscanf(in, "%f", x + i);
Going through the file twice may or may not be a performance hit. If the file is still in the cache, it may not....