summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/c/readFile.c
diff options
context:
space:
mode:
authorleochanj105 <leochanj@live.unc.edu>2020-10-19 23:09:30 -0400
committerleochanj105 <leochanj@live.unc.edu>2020-10-20 02:40:39 -0400
commitf618466c25d43f3bae9e40920273bf77de1e1149 (patch)
tree460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/common/c/readFile.c
parent47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff)
initial sd-vbs
initial sd-vbs add sd-vbs sd-vbs
Diffstat (limited to 'SD-VBS/common/c/readFile.c')
-rw-r--r--SD-VBS/common/c/readFile.c42
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/********************************
2Author: Sravanthi Kota Venkata
3********************************/
4
5#include "sdvbs_common.h"
6
7F2D* 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