Hello everyone, i'm new in c++ and i found a problem when created a code.
I want to create a code which read from file .txt and then count the number of each value of the attribute, as the text file below: the attribute is'bembi' and the value is '1,2,3'. And i want my code return the number of the value which will return 3 in this case.
The file:
bembi: 1, 2, 3.
lala: continuous.
kaka: continuous.
ohmy: 4,5.
My code is:
fseek(fInNames, position, SEEK_SET);
num=0;
while(fgets(string, BUFFSIZE, fInNames))
{
token = strtok(string, ":\t\n");
if ((token != NULL) && !strchr(token, '|'))
{
num2[num]=0;
notEnd = true;
while (notEnd)
{
MaxAttribute++;
token = strtok(NULL, ",\t");
if(token == NULL)
{
fgets(string, BUFFSIZE, fInNames);
token = strtok(string, ",\t");
}
else if (strchr(token, '|'))
notEnd = false;
else
{
num2[num]++;
if(token[strlen(token)-1] == '.')
notEnd = false;
}
printf("Sum of the atribut is %d\n", MaxAttribute++);
}
num++;
}
strcpy(string, "");
}
but, when i ran my code it keep looping and i don't know where exactly the error was..
Thank you so much.
Regards,
Sa