fork download
  1. %{
  2. #include <stdio.h>
  3. #include <ctype.h>
  4.  
  5. int vowels = 0;
  6. int consonants = 0;
  7. %}
  8.  
  9. %%
  10.  
  11. [aeiouAEIOU] { vowels++; }
  12. [b-df-hj-np-tv-zB-DF-HJ-NP-TV-Z] { consonants++; }
  13. .|\n { /* Ignore other characters */ }
  14.  
  15. %%
  16.  
  17. int main() {
  18. char input[1000]; // Buffer for user input
  19.  
  20. printf("Enter text: ");
  21. fgets(input, sizeof(input), stdin); // Read input from the user
  22.  
  23. YY_INPUT(yytext, input, sizeof(input)); // Use the input buffer as the source for Lex
  24.  
  25. yylex(); // Start Lex scanning
  26.  
  27. printf("Total vowels: %d\n", vowels);
  28. printf("Total consonants: %d\n", consonants);
  29. return 0;
  30. }
  31.  
Success #stdin #stdout #stderr 0.03s 6912KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/TeUIMc/prog:30:1: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit