fork download
  1. %{
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. FILE *outFile;
  5. %}
  6.  
  7. %%
  8. "<"[^>]+">" {
  9. fprintf(outFile, "%s\n", yytext);
  10. }
  11.  
  12. .|\n { /* Ignore all other content */ }
  13. %%
  14.  
  15. int yywrap()
  16. {
  17. return 1;
  18. }
  19.  
  20. int main(int argc, char *argv[])
  21. {
  22.  
  23. if(argc < 3)
  24. {
  25. printf("Usage: %s input.txt output.txt\n", argv[0]);
  26. return 1;
  27. }
  28. FILE *inFile = fopen(argv[1], "r");
  29. if(!inFile)
  30. {
  31. printf("Cannot open input file\n");
  32. return 1;
  33. }
  34.  
  35. outFile = fopen(argv[2], "w");
  36. if(!outFile)
  37. {
  38. printf("Cannot open output file\n");
  39. return 1;
  40. }
  41. yyin = inFile;
  42. yylex();
  43.  
  44. fclose(inFile);
  45. fclose(outFile);
  46.  
  47. printf("HTML tags extracted successfully!\n");
  48. return 0;
  49. }
  50.  
Success #stdin #stdout #stderr 0.03s 6960KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/kNJbhs/prog:49:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit