forked from CesarAng28/TDA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiles.c
More file actions
58 lines (46 loc) · 1.12 KB
/
files.c
File metadata and controls
58 lines (46 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include"files.h"
/**
* Instanciates a new file pointer identified via its name and mode.
* @param
* name (char *):
* Name of the file
* mode (char *):
* Mode of file to be opened {r, rb, a, ab, w, wb}
*
* @return FILE * opened_file.
*/
FILE * file_new(char *name, char *mode)
{
FILE * file;
file = fopen(name,mode);
return file;
}
/**
* Writes a bidimensional buffer array into a file.
* @param
* file (FILE *):
* Storage file
* columns (size_t ):
* length of the buffer array
* buff [ ][columns] (long double):
* RAM matrix
* rows (size_t):
* width of the storage buffer
*
* @return void.
*/
void file_num_write(FILE * file, size_t columns, long double buff[] [columns], size_t rows)
{
int count_rows,count_columns=0;
for(count_rows = 0;count_rows < rows;count_rows++)
{
fprintf(file,"%.0Lf ",buff[count_rows][count_columns]);
count_columns++;
fprintf(file,"%Lf ",buff[count_rows][count_columns]);
count_columns++;
fprintf(file,"%Lf",buff[count_rows][count_columns]);
count_columns=0;
fprintf(file,"\n");
}
fclose(file);
}