flex文件打不开

问题描述

我在使用 Lex imp 初学者时遇到问题,我正在尝试运行我的代码,但突然间它在我运行时开始显示文件无法打开”消息。它工作得很好,但我不知道当我试图解决我在使用 yywrap() 时遇到的错误时发生了什么。我在这里发现了一个类似的问题,但他们说将文件保存为所有类型 * 没有用。我已经尝试了几个小时,现在我不知道该怎么办。请帮助

%{
#include <stdio.h>
#include <string.h>
char temp[]="the"; 
char longWord[50];
char vwordCount=0;
int numRange [1000]={0};
int num=0;
int vCount=0;
char vowels[10000][1000];
int count =0;
%}





%%

[aeIoUAEIoU][a-zA-Z]+  {
   strcpy(vowels[vCount],yytext);
vCount++;
}




[0-9]+ {
   if (atof(yytext) > 70 && atof(yytext) < 50) {
      numRange[num] = atof(yytext);
      num = num +1;
   }

}//end  rule

[a-zA-Z]+ {

if(strcmp(yytext,temp)==0)
 count++;
    if ( strlen(yytext) > strlen(longWord))
         strcpy(longWord,yytext);
           }
.;    

%%


int yywrap()
{
   return 1;
}



int main()
{

extern FILE *yyin,*yyout;
      
    
          char text[] = "";
          printf("Enter  text file name: ");
          scanf("%s",text);
       yyin=fopen(text,"r");
       yylex();



       printf("\n The longest word in the file is %s",longWord);
       printf("\n There number of times %d \"The\"appeard in the file is : \n",count);


    printf("The count of numbers  in the given range :\n");
       for (int i = 0; i < num;  i++) {
           printf("%d,",numRange[i]);
       }


printf("\nThere are %d words that start with vowel letter. They are: \n",vCount);
       for (int i = 0; i < vCount; i ++ ) {
           printf("/n %s,vowels[i]);
       }


   return 0;
}


解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)