printFunction.c 534 B

123456789101112131415161718192021222324252627
  1. #include "printFunction.h"
  2. void printFloatVector(double* V, int length, char* fn) {
  3. int j;
  4. FILE* f = fopen(fn, "w");
  5. if (f != NULL) {
  6. for (j = 0; j < length; j++) {
  7. fprintf(f, "%20.18f\n", V[j]);
  8. }
  9. fclose(f);
  10. }
  11. else {
  12. printf("Error during writing file %s.\n", fn);
  13. }
  14. }
  15. void printIntVector(int* V, int length, char* fn) {
  16. int j;
  17. FILE* f = fopen(fn, "w");
  18. if (f != NULL) {
  19. for (j = 0; j < length; j++) {
  20. fprintf(f, "%d\n", V[j]);
  21. }
  22. fclose(f);
  23. }
  24. else {
  25. printf("Error during writing file %s.\n", fn);
  26. }
  27. }