PandA-2024.02
read_file.h
Go to the documentation of this file.
1 #ifndef H_READ_FILE_H
2 #define H_READ_FILE_H
3 
4 #include <stdlib.h>
5 #include <stdio.h>
6 
7 template <int DIM1, int DIM2, typename T> void read_file(char *filename, T outBuf[DIM1][DIM2] )
8 {
9  int i, j;
10 
11  float data;
12  char str[300];
13 
14  FILE *fid = fopen( filename, "r");
15  if (fid==NULL)
16  fprintf(stderr, "error in opening input file %s\n", filename);
17 
18  for (i = 0; i < DIM1; i++)
19  {
20  for (j = 0; j < DIM2; j++)
21  {
22  fscanf(fid,"%s", str);
23  data = atof(str);
24  outBuf[i][j] = (T) data;
25  //fprintf(stderr,"%f ", (float) data);
26  }
27  fscanf(fid,"\n");
28  //fprintf(stderr,"\n");
29  }
30 
31  fclose(fid);
32 
33  return;
34 }
35 
36 
37 
38 #endif
#define NULL
std::string filename
char str[25]
Definition: fixedptc.c:8
void read_file(char *filename, T outBuf[DIM1][DIM2])
Definition: read_file.h:7

Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by doxygen 1.8.13