void findRecords(char * str) {
char *pointer = strstr(str, "</");
if(pointer != NULL){
pointer += 2;
int i = 0;
while(i < strlen(pointer)){
if(pointer[i] == '>'){
pointer[i] = '\0';
break;
}
i = i + 1;
}
i = 0;
while(i < 1000) {
if (mainArray[i] != NULL) {
if (strcmp(mainArray[i], pointer) == 0) {
countArray[i] = countArray[i] + 1;
break;
}
i = i + 1;
} else {
mainArray[i] = pointer;
//printf("Index: %i, Array: %s, Pointer: %s\n", indexArray, mainArray[i], pointer);
countArray[i] = countArray[i] + 1;
break;
}
}
}
}
I wrote this method to collect all lines from a file which start with "</", I cut out the chars between "</" and ">" and finally saved them in "mainArray"
I can say for sure, that alle the "pointers" I write to "mainArray" are correct, but when I print out "mainArray" in a loop, there is just nonsense. Can someone explain me why this is happening?
char *mainArray[1000];
int countArray[1000];