0

I have strings in the following format:

<a href="../site0/page0_2279.html"> ../site0/page0_2279.html </a><br/>

What I am trying to do , is to store the href link to a string variable in C. My try so far, that doesn't seem to work:

char htmltag[200];
strcpy(htmltag,"<a href=\"../site0/page0_2279.html\"> ../site0/page0_2279.html </a><br/>");
char link[120];
char samelink[120];
sscanf(htmltag,"<a href=\"../%s\"> ../%s </a><br/>",link,samelink);
printf("%s %s\n",link,samelink);

Note: I am trying to get only the bold part of the link ../site0/page0_2279.html

EDIT:

I found a temporary solution that works for me , so I post it , but I leave it open for more appropriate ones.

char* link;
strtok(temp, "\"\""); // tokenize till first double quotes
link = strtok(NULL, "\"\""); // get the main part
printf("Link: %s \n",link+3); // remove ../
Social Programmer
  • 147
  • 1
  • 4
  • 12
  • 1
    see https://stackoverflow.com/questions/24483075/input-using-sscanf-with-regular-expression – Yunus Jun 03 '18 at 14:36
  • 1
    I'm not sure that you are using sscanf in the prober way! `int sscanf(const char *str, const char *format, ...);` – hassan Jun 03 '18 at 15:28

0 Answers0