Hello, again. For some reason, compiling works fine. But when run, I get bugs with fscanf. Now this obviously can't be Windows's fault. So is there something in the code that is causing this bug? I can't seem to find it.
Any help is appreciated.Code:// HTMLRandomizerDOS.cpp : Defines the entry point for the console application.
//
#include <ctype.h>
#include <stdio.h>
#include <string.h>
void stolower(char*a)
{
while (*a)
{
*a = tolower(*a);
a++;
}
}
int hrefreader(char *htmlpage,char* Links)
{
int numlinks = 0;
char *sp, *spe;
int irtn = 0;
if (sp = strstr(htmlpage, "href="))
{
sp += 6;
spe = strstr (sp, "\"");
strncpy (Links,sp,spe - sp);
irtn = 1;
}
return irtn;
}
int main(int argc, char* argv[])
{
int numlinks;
FILE *nfile;
char htmlpage[2500];
char Links[200][512]={102400*0};
int i,j;
nfile = fopen((const char*)"Google.htm","r");
i=0;
while (fscanf (nfile,"%s", htmlpage)!=EOF)
{
stolower (htmlpage);
j = hrefreader (htmlpage,(char*)Links[i]);
printf(" %s\n",Links[i]);
i = i + j;
}
for ( j=0; j<i;j++ ) {
printf(" %s\n",Links[j]);
}
return 0;
}