fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. /* maybe the buffer must be greater */
  6. char lineBuffer[256];
  7. // FILE *potential = fopen("orderedfile.txt", "r");
  8.  
  9. /* loop through every line */
  10. while (fgets(lineBuffer, sizeof(lineBuffer), stdin) != NULL)
  11. {
  12. double a, b, c;
  13. /* if there are 3 items matched print them */
  14. if (3 == sscanf(lineBuffer, "%lf %lf %*f %lf", &a, &b, &c))
  15. {
  16. printf("%f %f %f\n", a, b, c);
  17. }
  18. }
  19. // fclose(potential);
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 9432KB
stdin
BEGIN header

       Real Lattice(A)               Lattice parameters(A)    Cell Angles
   2.4675850   0.0000000   0.0000000     a =    2.467585  alpha =   90.000000
   0.0000000  30.0000000   0.0000000     b =   30.000000  beta  =   90.000000
   0.0000000   0.0000000  30.0000000     c =   30.000000  gamma =   90.000000

 1                            ! nspins
25   300   300                ! fine FFT grid along <a,b,c>
END header: data is "<a b c> pot" in units of Hartrees

 1     1     1            0.042580
 1     1     2            0.049331
 1     1     3            0.038605
 1     1     4            0.049181
stdout
1.000000 1.000000 0.042580
1.000000 1.000000 0.049331
1.000000 1.000000 0.038605
1.000000 1.000000 0.049181