Hey everyone,
I've got a situation, I am building a search engine and i am trying to produce one big char pointer that points to all text that is not a tag in an html file.
I do this by reading the html file, line by line, removing tags from each line(by calling removeTag), then adding the line w/o tags to the end of my big char pointer. But alas, it is not working.
You can assume that all my functions that i call are working normally, since i've already debuged them. the error has to be where i add duplicate to the bigPtr. Any suggestions are welcome. Thanks everyone.
The Landroid
Oh yeah, ignore my print statements, they are just for debuging and seeing what is going where.
Code:
char* getNoTags(char* url)
{
//printf("IN GET NO TAGS");
char contentType[ MaxLineLength ];
char* duplicate;
int counter;
char* bigPtr;
int x = 0;
int y = 0;
char line[MaxLineLength];
bigPtr = new char[10000];
FILE * f = openhttp( url, contentType );
if ( f == NULL ) {
exit(1);
}
// Print the content type
//printf( "Content Type: \"%s\"\n", contentType );
while ( fgets( line, MaxLineLength, f ) ) {
duplicate = removeTag(line,MaxLineLength);
//printf("%s",duplicate);
y = 0;
do{
bigPtr[x] = duplicate[y];
x++;
y++;
printf("%c",bigPtr[x]);
}while(duplicate[y] != '\0');
//printf("i've made it out\n");
}
printf("\ni'm outside everything\n");
fclose(f);
//bigPtr[x] = '\0';
//printf("bigPTR: %s\n",bigPtr);
printf("returning\n");
return bigPtr;
}