>>it searches through the html file for URL strings (which are in quotes)
If you're talking about any old web page, then no, they're not guaranteed to be in quotes.
A link could be coded like <a href=link.htm>
Also, quotes aren't the only criteria you need to think about. The URL starts after the href element of an anchor tag. This means your code needs to be smarter than simply looking for the next quote in the text.
My suggestion, create a variable that represents the current "state" or what you're looking for. It's hard to explain (especially late at night!), so here's an example of what I mean. It doesn't work to the level of detail that is required to properly parse HTML, but might give you a bit of an idea.
Code:
#include <stdio.h>
#define INURL 1
#define NOT_INURL !INURL
int main(void)
{
char *html = "this a <a href=\"link.htm\">link</a>.";
char url[BUFSIZ];
char *url_p;
char *p;
int State;
puts (html);
for (State = NOT_INURL, p = html, url_p = url;
*p;
p++)
{
if (*p == '\"')
{
State = !State;
printf ("Now %s in url\n", State == INURL ? "" : "not");
continue;
}
if (State == INURL)
{
*url_p = *p;
url_p++;
}
}
*url_p = '\0';
puts (url);
return(0);
}
/*
* buffer overflow checking omitted!
*/
I'd also suggest you research how to properly use multi-dimensional arrays before trying to intergrate them into your program. I don't know how much you understand, so forgive this simple example:
Code:
#include <stdio.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
int main(void)
{
char list[2][3] = { "abc", "efg"};
int i, j;
for (i = 0; i < ARRAY_SIZE(list); i++)
for (j = 0; j < ARRAY_SIZE(list[i]); j++)
putchar (list[i][j]);
return(0);
}