LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-21-2004, 08:32 AM   #1
chuanyung
LQ Newbie
 
Registered: Jan 2004
Posts: 25

Rep: Reputation: 15
[C++][flex++] What's wrong to get first string?


Dear all,

My rule is:
---------------------------
white ([ \t]+)

%%
{white} ;
[^ \t\n]+ {printf("Got string = %s\n",YYText());}
. ECHO;
\n ;

%%
--------------------------

My input is a file, for example test.txt
test.txt:
--------------------------
abcd123 1000
.
.
.
--------------------------

I can get first string is "abcd123".


But if test.txt's first lines are blanked (only '\n'),
for example the first 2 lines are just '\n'.
I got first string is "\n\nabcd123".

What's wrong?
How should I fix it?

Thanks for your help.

Best Reards,
cylin.
 
Old 07-21-2004, 10:19 PM   #2
chuanyung
LQ Newbie
 
Registered: Jan 2004
Posts: 25

Original Poster
Rep: Reputation: 15
I solve it.

If a file is DOS mode,
then you must remeber to add '\r' and combine '\n' to get end of line.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
I need a flex package cstj Linux - Software 1 10-04-2005 11:37 PM
flex input from string sibtay Programming 0 12-21-2004 06:14 AM
anyone knows how to use flex???? tuxfood Programming 1 04-27-2004 06:17 AM
java test if string in string array is null. exodist Programming 3 02-21-2004 01:39 PM
flex your lex chens_83 Linux - General 2 06-02-2002 03:18 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration