RandomTroll |
07-13-2019 06:50 AM |
Quote:
Originally Posted by rtmistler
(Post 6014502)
Can't really tell what you're trying to do.
|
I want a program to read parameters from a configuration file instead of the command line. For instance I want to have a plain-text initialization file that looks like:
Quote:
Fruit: Apple
Fish: Trout
Vegetable: Asparagus
|
and have the program assign the value Apple to the variable Fruit...
Quote:
Originally Posted by rtmistler
(Post 6014502)
One can also look at the source code for each of grep and also strstr().
|
Duh. I can also write it in assembly and use no libraries.
Quote:
Originally Posted by individual
(Post 6014511)
There isn't a convenient function included with the standard library
|
It's done so often that surprises me. I found getconf and confstr, but they don't seem to apply
Quote:
Originally Posted by individual
(Post 6014511)
If you want I'll share a function that I use when I need simple pattern matching.
|
That'd be nice. I started by fopen-ing it, reading it line-ly with getline, picking out the first word, running that through switch on all the possible variables.
Later: discovered strtok, the function perfect for separating elements on a line.
|