in the following code, I ran into a problem where I had a string from getString method then it was fine until I entered the loop, then I lost the string. I don't know why I lost the sting it should be within the stack.
int main(int argc, char *argv[1]){
char * str;
getString(str, 100000);
char * ID[100];
int num[100];
for(int i =0 ; i < 100; i ++){
num[i]=0;
}
int j = 0;
for(int i =0; i < sizeof(str);i++){
if( str[i] == '<'){
char * strPoint = (str+i+1);
int ln = findLenth(strPoint);
char * strCom = malloc(ln*sizeof(char));
memcpy(strCom, str, ln);
int r = tag(ID, strCom, &j);
if(r != -1){
num[r]++;
}
}
}
for(int r = 0; r <j; r++){
printf("%s %d\n", ID[r], num[r]);
}
freeMemory(ID, j);
return EXIT_SUCCESS;
}
void getString(char* str, int i){
fgets (str, i, stdin);
}