ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Like Tink said it would depend on the post-processing. The steps that would be involved may be:
1) Open a file
2) Read a line using 'fgets'
3) Use 'sscanf' to read in the 30 numeric values in 30 different variables.
4) Do the required processing on these variables
5) If not EOF then go back to step 2
Well, the post processing hasn't been determined yet. I'm just trying to find out the best way to parse line by line just to extract the data from said text data file, and feed the data into something else... say a viewport on screen... or even print it to the console as it scrolls in.
Thanks. I was just trying to figure out between fgets, scanf, and just soaking up the entire string into an array to be parsed however. (given the fixed format)
I guess I could put a simple loop in to check for the '\n' and EOF so I can parse it all at once and throw it to the correct place in code.
Do look into strtok() and strstr() functions. For variable number of numeric values you can first read a line with fgets() and then one by one read a numeric value using strtok(). The you can use sscanf() to read that value as an interger.
My suggestion is to use lex/flex, or some regular expression lib. It may not run as quickly as a man-code parser, but the code will be very easy to read and change.
Last edited by powerplane; 05-16-2003 at 09:08 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.