Computer Games Forum
 

Go Back   Computer Games Forum > Tech > The Workshop > Limbaje de programare

Notices

Căutare produse PC Garage: Şterge căutarea

Reply
 
LinkBack Thread Tools
Old 20-05-2006, 22:14   #1 (permalink)
Registered User
 
Join Date: Apr 2006
[FLEX] problema

Am o problema cu urmatorul program :



%{
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
int num_lines = 0, num_chars = 0;int cuvinte = 0;
int nume[100];int prenume[100], contor=0,cnt=0;
%}


%s NUM s1 PRENUM s2 CodIBAN s3 STARE_X NumarCONT s4


SEP [ \t\n]+
LITERA [A-Za-z]
CIFRA [0-9]
nume [a-zA-Z]+
prenume {nume}|{nume}"-"{nume}
INDICATIV_TARA '"RO"'
INDICATIV_BANCA {LITERA}{2}| {LITERA}{3} | {LITERA}{4}
CodIBAN {INDICATIV_TARA}{CIFRA}{2}{INDICATIV_BANCA}{CIFRA}{16}
NUMAR_CARD {CIFRA}{4}"-"{CIFRA}{4}"-"{CIFRA}{4}"-"{CIFRA}{4}
%%
<INITIAL>
{nume} {
contor++;cnt++BEGIN (NUM);
}
<NUM>
{
BEGIN (s1);
}
<s1>
{SEP} {
cnt++;BEGIN (PRENUM);
}
<PRENUM>
{prenume} BEGIN (s2);
<s2>
{SEP} {
cnt++;BEGIN (INITIAL);
}
%%

main(int argc, char ** argv){
yyin = fopen("intrare.txt","r");
FILE * fout = fopen("iesire.txt","wt");
yylex();

fprintf(fout,"# of persons = %d, # of white spaces = %d", contor,cnt);

}




Problema e ca nu stiu de ce intra doar prin starea initial pentru un fisier de intrare care contine liniile urmatoare:

MIHAELA MIHAI
ANTON ROMAN
DEA BUNEA


Rezultat :
"# of persons = 1, # of white spaces = 1"


Any idea,anyone?
Multumesc.
 
dea.altec is offline    Reply With Quote
Advertisment
Reply

  Computer Games Forum > Tech > The Workshop > Limbaje de programare

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +2. The time now is 22:59.


Advertisement System V2.5 By   Branden
This site is copyrighted ©1997 - 2008, Computer Games Online SRL