I have one CSVReader class, which has this function
vector<UtfChar*> CSVFile::ReadFile(FILE* fp)
{
//int count = 0;
Utf8Char buff[256];
fgets(buff, 256, (FILE*)fp);
// count++;
Utf8Char *token = strtok(buff, ",");
bvector<UtfChar*> localVec;
while (token != NULL)
{
localVec.push_back(token);
token = strtok(NULL, ",");
}
return localVec;
}
Now I have another class, from which I am calling this function:
FILE *fp;
fp = fopen("SampleFile.csv", "r");
while((getc(fp)) != EOF)
{
bvector<Utf8Char*> localVec = csvFile.ReadFile(fp);
}
Here i am comparing values of localVec
with some set of values (char*
) I have. But in this other class, when I am trying to access vector like localVec[0]
or localVec[1]
, it is giving a garbage.
I tried with comparison in CSVReader class itself, then its working there. But I need to do comparison in other class, so that i can use same CSVReader class for other CSV Files.