From ffcb0f4445e8599df2cb7a300717a505d2351d0d Mon Sep 17 00:00:00 2001 From: mtzikara Date: Sun, 9 Sep 2018 17:37:14 +0200 Subject: [PATCH] Add files via upload --- serial.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 serial.c diff --git a/serial.c b/serial.c new file mode 100644 index 0000000..6fe60d9 --- /dev/null +++ b/serial.c @@ -0,0 +1,88 @@ +#include +#include + + +void main(){ + printf("Hello I am maria \n"); + + //Read from file of adjacency matrix + FILE *adjm; + + int x; + adjm = fopen("adj_matrix.txt", "r+"); + if(!adjm){ + printf("Error opening file \n"); + exit(0); + } + + //Read dimensions of file (square) + int m, count=0; + while((m=fgetc(adjm))) { + /* break if end of file */ + if(m == EOF) break; + /* otherwise add one to the count of that particular character */ + if(m=='\n'){ + count+=1; + } + } + printf("Line count of matrix is %d \n", count); + int d = count; + int i,j; + + // Put values in matrix A + int** A = malloc(d*sizeof(int *)); + for( i=0; i