I want to install the data that i read from a csv file into matrix. Here is my code:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define BUFSIZE 1024
int main()
{
char *filename = "pb0.csv";
char str[BUFSIZE];
FILE *fpr;
fpr = fopen(filename, "r");
while (fgets(str, BUFSIZE, fpr) != NULL) {
printf("%s", str);
}
fclose(fpr);
return 0;
}
My output be like:
2; 2; 1; 5; 0; 4
2; 0; 2; 1; 4; 6
2; 2; 1; 4; 6; 5
4; 4; 6; 0; 1; 3
2; 3; 1; 5; 6; 0
I want to write a code which will store all that string of numbers into matrix maybe look like this:
2 2 1 5 0 4
2 0 2 1 4 6
2 2 1 4 6 5
4 4 6 0 1 3
2 3 1 5 6 0
What should i write? Any help will be appreciated.