View Code of Problem 98

#include<stdio.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>


int main(){
    char ch[256];
    char name[128];
    int i;
    int l,r;
    while(1){
        if(gets(ch) == NULL)
            break;
        if(!strcmp(ch,"</xmp>"))
            break;
        if(strstr(ch,"h3") != NULL){
            sscanf(ch, "%*[^>]>%[^<]", name);
            // for(i = 0;i < strlen(ch);i++){
            //     if(ch[i] == '>'){
            //         if(l == 0)
            //             l = i;
            //     }
            //     else if(ch[i] == '<'){
            //         r = i;
            //     }
            // }
            // strncpy(name,ch + l + 1,r - l - 1);
        }
        if(strstr(ch,"In Stock") != NULL){
            printf("%s\n",name);
        }
        l = 0;
        r = 0;
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 98