fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. char *p="<PLETZHALTER> protocol=pp11 <PLATZHALTER> portid=12345 <PLATZHALTER> name=pp22";
  6. {
  7. char s[100],s1[100],s2[100];
  8. unsigned i=0,u;
  9. while(1==sscanf(p+=i,"%99s%n",s,&i))
  10. if(strstr(s,"protocol=")==s)
  11. strcpy(s1,s+9);
  12. else
  13. if(strstr(s,"name=")==s)
  14. strcpy(s2,s+5);
  15. else
  16. if(strstr(s,"portid=")==s)
  17. sscanf(s+7,"%u",&u);
  18. printf("%s %s %u",s1,s2,u);
  19. }
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
pp11 pp22 12345