#include<stdio.h> //大佬仅仅几行代码解决,令人敬佩 #include<string.h> #include<math.h> int main(){ char ch[256]; char name[128]; while(1){ if(gets(ch) == NULL) break; if(!strcmp(ch,"</xmp>")) break; if(strstr(ch,"h3")!=NULL){ //strstr()返回子串地址,如果没有返回NULL sscanf(ch, "%*[^>]>%[^<]", name); //读取从字符>到字符<的字符串到name中,*表示跳过不读入 } if(strstr(ch,"In Stock")!= NULL) printf("%s\n",name); } } |
Double click to view unformatted code.