Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. BEGIN header
  2.  
  3. Real Lattice(A) Lattice parameters(A) Cell Angles
  4. 2.4675850 0.0000000 0.0000000 a = 2.467585 alpha = 90.000000
  5. 0.0000000 30.0000000 0.0000000 b = 30.000000 beta = 90.000000
  6. 0.0000000 0.0000000 30.0000000 c = 30.000000 gamma = 90.000000
  7.  
  8. 1 ! nspins
  9. 25 300 300 ! fine FFT grid along <a,b,c>
  10. END header: data is "<a b c> pot" in units of Hartrees
  11.  
  12. 1 1 1 0.042580
  13. 1 1 2 0.049331
  14. 1 1 3 0.038605
  15. 1 1 4 0.049181
  16.  
  17. int readinputfile(){
  18. FILE *potential = fopen("orderedfile.txt", "r");
  19. for (i=0; i<size; i++){
  20. fscanf(potential, "%lf %lf %*f %lf", &x[i], &y[i], &V[i]);
  21. }
  22. fclose(potential);
  23. }
  24.  
  25. int res = fscanf(potential, "%lf %lf %*f %lf", &x, &y, &v);
  26. if (res == EOF) break;
  27. if (res != 3) {
  28. fscanf(potential, "%*[^n]");
  29. }
  30.  
  31. #include <stdio.h>
  32.  
  33. int main()
  34. {
  35. char lineBuffer[256];
  36. FILE *potential = fopen("orderedfile.txt", "r");
  37.  
  38. while(fgets(lineBuffer, sizeof(lineBuffer), potential) != NULL)
  39. {
  40. double a, b, c;
  41. if (3 == sscanf(lineBuffer, "%lf %lf %*f %lf", &a, &b, &c))
  42. {
  43. printf("%f %f %fn", a, b, c);
  44. }
  45. }
  46. fclose(potential);
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement