SHARE
TWEET

Untitled

a guest Oct 21st, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Function definitions for operations on vectors in 3-space.
  2.  
  3. #include <stdio.h>
  4. #include "vec6C.h"
  5.  
  6. int save_precisely(const char *filename, const vec_t *a, int n)
  7. {
  8.     int i, fcl;
  9.     FILE *fp;
  10.    
  11.     fp = fopen (filename, "w");
  12.     if (fp == NULL)
  13.         return OPEN_FAILED;
  14.  
  15.     for (i = 0; i < n; i++)
  16.     {
  17.         fprintf(fp,"%.20e %.20e %.20e\n", a[i].x, a[i].y, a[i].z);
  18.     }
  19.    
  20.     fcl = fclose(fp);
  21.     if (fcl != 0)
  22.         return CLOSE_FAILED;
  23.  
  24.   return SUCCESS;
  25. }
  26.  
  27. int save_fancily(const char *filename, const vec_t *a, int n)
  28. {
  29.     int i, fcl;
  30.     FILE *fp;
  31.    
  32.     fp = fopen (filename, "w");
  33.     if (fp == NULL)
  34.         return OPEN_FAILED;
  35.  
  36.     for (i = 0; i < n-1; i++)
  37.     {
  38.         fprintf(fp, "element %d: (%.4f, %.4f, %.4f) \n", i, a[i].x, a[i].y, a[i].z);
  39.     }
  40.    
  41.     fcl = fclose(fp);
  42.     if (fcl != 0)
  43.         return CLOSE_FAILED;
  44.  
  45.   return SUCCESS;
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top