reading a config file

J

jan olieslagers

My project is advancing fast, thanks to the good help some of you
managed to give me between calling each other names, scaring off
newcomers both to the C language and to this forum, and discussing
irrelevancies such as penis sondage, the right spelling of dictator's
names and the sex of angels &C &C

Next task is to read from a config file some parameters which up to now
were hardcoded for the sake of getting at least _something_ to work. In
awk I'd manage well enough, but as a newcomer to the C language I don't
feel like spending many hours to reinvent the wheel, especially with
this flu-ish fever running in my brain. Surely there must be some sample
code somewhere on the www, any pointers please?

As always, be assured of my gratitude,
KA
 
T

Tomás Ó hÉilidhe

Next task is to read from a config file some parameters which up to now
were hardcoded for the sake of getting at least _something_ to work. In
awk I'd manage well enough, but as a newcomer to the C language I don't
feel like spending many hours to reinvent the wheel, especially with
this flu-ish fever running in my brain. Surely there must be some sample
code somewhere on the www, any pointers please?


There's really very little to it. It's the kind of thing you "consult
a reference for" instead of actually learning. You'd have it written
in 20 minutes (well 5 minutes if you throw it together).

First of all, open the file with fopen, then just use fread, fgets,
fgetc.

Here's a good reference:

http://www.dinkumware.com/manuals/?manual=compleat&Search=fopen&page=stdio.html#fread
 
C

Chad

There's really very little to it. It's the kind of thing you "consult
a reference for" instead of actually learning. You'd have it written
in 20 minutes (well 5 minutes if you throw it together).

First of all, open the file with fopen, then just use fread, fgets,
fgetc.

Here's a good reference:

http://www.dinkumware.com/manuals/?manual=compleat&Search=fopen&page=...

The OP also might want to use something like sprintf() if there are
spaces in the config file. Ie, something like

printer1 bldg1
printer2 bldg2

But other than that, I agree that it is probably a 5 minute task.
 
A

Antoninus Twink

jan olieslagers said:

comp.sources.wanted

Yeah, great, Heathfield.

A group that even the spammers haven't posted to since the middle of
August according to
<http://groups.google.com/group/comp.sources.wanted/topics>.

This is absolutely typical of the "helpful advice" you and your cronies
like to give out. "Ask in that other group - that's where the experts
are, they'll help you and correct people's mistakes". Bullshit. No one
is in comp.sources.wanted - the tumbleweed is blowing around its
once-great halls. Advising someone to post there just to keep "your" clc
unpolluted with real-world questions is about as unhelpful as it's
possible to be.
 
J

jan olieslagers

Malcolm McLean schreef:
There's one on my website.
It's a good question whether it is easier simply ti hardcode your own
config file loader. However you are welcome to use my generic one.

Thank you Sir, is it much to ask for a pointer to this your said website?
 
R

Richard

Richard Heathfield said:
jan olieslagers said:


You're welcome.

Could you be less helpful?

To the OP : take a look at many of the Open Source projects held on
sourceforge. Ignore Heathfield and CBF as much as possible. They are
here to listen to their own voices and not to help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

reading a config file 1

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top