-
Notifications
You must be signed in to change notification settings - Fork 5
/
realcuda.cc
46 lines (39 loc) · 918 Bytes
/
realcuda.cc
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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void read_schedule(const char* file_name, int matrix[12][5])
{
char buffer[1024] ;
char *record,*line;
int i=0,j=0;
FILE *fstream = fopen(file_name,"r");
if(fstream == NULL)
{
printf("\n file opening failed ");
return ;
}
while((line=fgets(buffer,sizeof(buffer),fstream))!=NULL)
{
record = strtok(line,",");
while(record != NULL)
{
//printf("record : %s",record) ; //here you can put the record into the array as per your requirement.
matrix[i][(j++)%5] = atoi(record) ;
record = strtok(NULL,",");
}
++i ;
}
return ;
}
int main(){
const char* name = "dir.csv";
int matrix[12][5];
read_schedule(name,matrix);
for(int i =0;i<12;i++){
for(int j = 0;j<5;j++){
printf("%d ",matrix[i][j]);
}
printf("\n");
}
return 0;
}