diff options
Diffstat (limited to 'SD-VBS/common/c/readFile.c')
-rw-r--r-- | SD-VBS/common/c/readFile.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/SD-VBS/common/c/readFile.c b/SD-VBS/common/c/readFile.c new file mode 100644 index 0000000..2c16abd --- /dev/null +++ b/SD-VBS/common/c/readFile.c | |||
@@ -0,0 +1,42 @@ | |||
1 | /******************************** | ||
2 | Author: Sravanthi Kota Venkata | ||
3 | ********************************/ | ||
4 | |||
5 | #include "sdvbs_common.h" | ||
6 | |||
7 | F2D* readFile(unsigned char* fileName) | ||
8 | { | ||
9 | FILE* fp; | ||
10 | F2D *fill; | ||
11 | float temp; | ||
12 | int rows, cols; | ||
13 | int i, j; | ||
14 | |||
15 | fp = fopen(fileName, "r"); | ||
16 | if(fp == NULL) | ||
17 | { | ||
18 | printf("Error in file %s\n", fileName); | ||
19 | return NULL; | ||
20 | } | ||
21 | |||
22 | fscanf(fp, "%d", &cols); | ||
23 | fscanf(fp, "%d", &rows); | ||
24 | |||
25 | fill = fSetArray(rows, cols, 0); | ||
26 | |||
27 | for(i=0; i<rows; i++) | ||
28 | { | ||
29 | for(j=0; j<cols; j++) | ||
30 | { | ||
31 | fscanf(fp, "%f", &(subsref(fill,i,j)) ); | ||
32 | } | ||
33 | } | ||
34 | |||
35 | fclose(fp); | ||
36 | return fill; | ||
37 | } | ||
38 | |||
39 | |||
40 | |||
41 | |||
42 | |||