Hello everyone this is my first post.
My problem is reading from a text file. The file is in the format: name\tdouble\tdouble\tdouble int
Since I have no control over the format of the file and do not know the size, I first begin by counting the lines of the file(nLineCount2). My question is, is fscanf the best/easiest way to read this file?
Sample of my code:
FILE *f;
f = fopen(sFileName.c_str(), "r");
for(int i = 0; i < nLineCount2; i++)
{
fscanf(f, "%s\t%lf\t%lf\t%lf %d", &name[0][i], &Data[1][i], &Data[0][i], &Data[2][i], nType[i]);
}
fclose(f);
The problem I'm running into is how to read the string in. I first made an array of strings, but fscanf needs character strings. Then I made a 2d character array. I can't seem to get either one to work and I'm wondering if fscanf is the way to go. Any input would be great. Thanks in advance.