fork download
  1. %option noyywrap
  2.  
  3. %{
  4. #include <stdio.h>
  5. int v = 0;
  6. int c = 0;
  7. %}
  8.  
  9. %%
  10.  
  11. [AEIOUaeiou] { v++; }
  12. [A-Za-z] { c++; }
  13.  
  14. %%
  15.  
  16. int main() {
  17. printf("Enter a string:\n");
  18. yylex();
  19. printf("Vowels: %d\n", v);
  20. printf("Consonants: %d\n", c - v); // Subtract vowels from total letters to get consonants
  21. return 0;
  22. }
  23.  
Success #stdin #stdout #stderr 0.02s 6940KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/Usv7Ja/prog:22:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit