Coder's Guild Mailing List

Re: questions on reading in a file (detailed)

Posted by Frank Hale on 1999-10-29

You may want to research a program called Flex or
Flex++ which lets you define how a scanner will
operate and it will create the necessary functions to
parse your file and return the data you desire. It
outputs ANSI C or if you use Flex++ will output a C++
file for inclusion into your project. 

The program Flex or Flex++ can be found by going to
www.gnu.org . There is a port of it to DOS which can
be called from a DOS box in windows. 

The output scanner from Flex should compile without a
problem in Visual C++.

Soon as I get home I will pass on some links to some
tutorials for Flex. 

--- Matthew Kaoru Hallberg <matthew@xxxxxxxx.xxx>
wrote:
> Hi. 
> It's me again, and yet another question for all of
> you. 
> I solved my struct problem, thanks for the help but
> now I have a new 
> question.... (still for visual c++ 6.0)
> is it possible to read in more than one line at a
> time using sscanf? 
> suppose I have a data file that has contents like
> this: 
>           
> F0000000: FF043000 FF043000 00000000 00000000 
> F0000010: 7F000000 7F000000 FF070000 FF070000 
> F0000020: 00000000 00000000 A0070000 A0070000
> 
> and I want to read in the first occurence of
> register 8 
> go to the next line, and read in the occurence of
> reg 10 
> like this (don't care about anything else... just
> those two values): 
>                  register10                 register
> 8
> F0000000: FF043000 FF043000 00000000 00000000 
>                                               
> ^^^^^^^^^^^ 1st read
> F0000010: 7F000000 7F000000 FF070000 FF070000 
>                 ^^^^^^^^^^^ 2nd read 
> F0000020: 00000000 00000000 A0070000 A0070000 
> //you get the point?.... 
> and store them into the variables:
> RegFuncData.HiAddr, and RegFuncData.LoAddr 
> this is what I had prior to finding out I needed to
> skip the initial register 
> 10 column 
> 
> while(ar.ReadString(strOneLine))
> {
>        sscanf(strOneLine,"(somehow skip ahead 11
> spaces) 8%u (somehow skip
>      ahead 10 spaces) ", &RegFuncData.LoAddr,
> &RegFuncData.HiAddr); 
>        // adds the data to the array 
>        m_RegisterArray.Add(RegFuncData);
> }
> 
> Can anyone help me out with the indicated problems? 
> I am using visual C++ 6.0, thanks a bunch... 
> -matt
> 
> 
>
> > Matthew Hallberg
> Assistant Engineer
> Galileo Technologies
> 408-367-1400 ext 237
> matthew@xxxxxxxx.xxx 
> > To signoff go to
> http://www.netalive.org/codersguild/webinterface/
> 

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com