Hello everyone, i have a problem in my code. I want to make 2D vector with type char and the char read from a file, because i want to make it as dynamic array regarding the size of input can be different.
Here is my file: bla.txt
K1, K2.

atribut1: 1, 2, 3.
atribut2: continuous.
atribut3: continuous.
atribut4: 4, 5.
I want to read from atribut1, which is after skip the line above atribut1(K1, K2. and \n). After that, the attribute for example atribut1 is save to vector, and the value of atribut1 (1,2,3) is saved as the 2D array, here is my expectation:

attName[0] = atribut1
attValName[atribut1] [0] = 1;
attValName[atribut1] [1] = 2;
attValName[atribut1] [2] = 3;

Here is my code:

char *token;
unsigned short num=0, atributV=0, num2[MAXATTRVAL], ii;
fseek(fInNames, position, SEEK_SET);
while(fgets(string, BUFFSIZE, fInNames))
	token = strtok(string, ":\t\n");
	//int atribut = 0;
		printf("attribute number: %d\n", atributV);
		//printf("atribut %s\n", token);
		aneh = strdup(token);
		while ((token = strtok(NULL,", ")) != NULL)
			aneh2 = strdup(token);
			printf("value of the attribute %d: %s\n", atributV, aneh2);	
		printf("amount of the attribute %d: %d\n\n", atributV,num2[atributV]);
		//if(atribut == 1)
	strcpy(string, "");

the result wasn't satisfying:
1. It keeps reading from the very beginning not from atribut1(which is before ':')
2. it gives me the result of non-2d array...i don't know how to make attribute value become the 2D array.
attribute number: 0
jumlah nilai atribut ke 0: 0

attribute number: 1
value of the attribute 1: 1
value of the attribute 1: 2
value of the attribute 1: 3.

amount of the attribute 1: 3

attribute number: 2
value of the attribute 2: continuous.

amount of the attribute 2: 1

attribute number: 3
value of the attribute 3: continuous.

amount of the attribute 3: 1

attribute number: 4
value of the attribute 4: 4
value of the attribute 4: 5.

amount of the attribute 4: 2

I really need help here, :(
thank you so much

This question has already been answered. Start a new discussion instead.