Project

General

Profile

« Previous | Next » 

Revision 9a7268ba

Added by Pierre-Loïc Garoche about 5 years ago

io_frontend header with new functions

View differences:

include/io_frontend.h
23 23
extern void _put_int(FILE* file, char* n, int _V);
24 24

  
25 25
/*@ assigns \nothing; */
26
extern void _put_double(FILE* file, char* n, double _V);
26
extern void _put_float(FILE* file, char* n, float _V, int PREC);
27

  
28
/*@ assigns \nothing; */
29
extern void _put_double(FILE* file, char* n, double _V, int PREC);
27 30

  
28 31
#endif
include/io_frontend.hpp
80 80
  printf("\n");
81 81
  fprintf(file, "%d\n", _V);
82 82
}
83
void _put_double(FILE* file, char* n, double _V){
83

  
84
void _put_float(FILE* file, char* n, float _V, int PREC){
85
  if(ISATTY) {
86
    printf("%s = ", n);
87
  } else {
88
    printf("'%s': ", n);
89
  };
90
  printf("'%.*f' ", PREC, _V);
91
  printf("\n");
92
  fprintf(file, "%.*f\n", PREC, _V);
93
  fflush(file);
94
}
95

  
96
void _put_double(FILE* file, char* n, double _V, int PREC){
84 97
  if(ISATTY) {
85 98
    printf("%s = ", n);
86 99
  } else {
87 100
    printf("'%s': ", n);
88 101
  };
89
  printf("'%f' ", _V);
102
  printf("'%.*f' ", PREC, _V);
90 103
  printf("\n");
91
  fprintf(file, "%f\n", _V);
104
  fprintf(file, "%.*f\n", PREC, _V);
105
  fflush(file);
92 106
}
93 107

  
108

  
94 109
#endif

Also available in: Unified diff