>>Following code gives me an error when I use text field in CSV file instead of float or integer fields
what compiler? post the errors. The compiler should give you warnings that it is converting int to char and may lose data.
what does the csv file look like -- can you post the first two or three lines? Are the values between -127 and 126 because that is the range of signed char. If the csv file contains larger numbers then you will have to redeclare the matrix as a 2d array of ints, not chars
int matrix_points[6][8];
and the while loop is incorrect. use of eof() is unpredictable.
// while(!(input_file.eof()))
//{
while( input_file.getline(line, sizeof(line), ',') > 0)
{
// blabla
}
>> printf("%s", matrix_points[i][0]);
all these lines are incorrect -- %s expects a null-terminated string, and what you are passing is just one character. They should look like this
printf("%s", matrix_points[i]);
This assumes that the array is null-terminated strings. If not, then %s will not work -- probably crash your program. In that case, change %s to %c as your original post
printf("%c", matrix_points[i][0]);
Finally, you can use loops to make the program more efficient. You can replace all those getline()s with just this one.
int r = 0, c = 0;
while( input_file.getline(line, sizeof(line), ',') > 0)
{
matrix_points[r][c] = (char)atoi(line);
++c;
if( c == 8)
{
r++;
c = 0;
}
}