Hi All,
Following code gives me an error when I use text field in CSV file instead of float or integer fields.
matrix_points[cnt][4] = atoi(line);
May be the problem with above line. Please see the below code
char matrix_points[6][8];
std::ifstream input_file("C:/NDA/NissanNewApplication/Dev/CommonErrorManager/Src/ErrorMessageList.csv");
int cnt(0);
printf("initial valie of cnt = %d\n",cnt);
char buffer[256];
char line[255];
input_file.clear();
input_file.seekg(0);
while(!(input_file.eof()))
{
input_file.getline(line, sizeof(buffer), ',');
matrix_points[cnt][0] = line;
//printf(" %s", line);
input_file.getline(line, sizeof(buffer), ',');
matrix_points[cnt][1] = atoi(line);
//printf(" %s", line);
input_file.getline(line, sizeof(buffer), ',');
matrix_points[cnt][2] = atoi(line);
//printf(" %s", line);
input_file.getline(line, sizeof(buffer), ',');
matrix_points[cnt][3] = atoi(line);
//printf(" %s", line);
input_file.getline(line, sizeof(buffer), ',');
matrix_points[cnt][4] = atoi(line);
//printf(" %s", line);
input_file.getline(line, sizeof(buffer), ',');
matrix_points[cnt][5] = atoi(line);
//printf(" %s", line);
input_file.getline(line, sizeof(buffer), ',');
matrix_points[cnt][6] = atoi(line);
//printf(" %s", line);
input_file.getline(line, sizeof(buffer), ',');
matrix_points[cnt][7] = atoi(line);
//printf(" %s", line);
cnt++;
}
for (int i=0; i<cnt; i++){
printf("%s", matrix_points[0]);
printf(" %s", matrix_points[1]);
printf(" %s", matrix_points[2]);
printf(" %s", matrix_points[3]);
printf(" %s", matrix_points[4]);
printf(" %s", matrix_points[5]);
printf(" %s", matrix_points[6]);
printf(" %s\n", matrix_points[7]);
}