3
31337one
Hello all,
Let me introduce myself. I would say that I am an intermediate
programmer in C++. I am studying comptuer science in college. However,
I have never had a formal introduction to buffers. Here is my problem:
I have a program that can have a config file and also command line
arguments.
When it executes I want to grab the command line arguements and stuff
them into a buffer (i think). Then i want to read everything from the
config file which is basically command line flags that are set and
stuff them into the buffer also.
The problem I am seeing is a "buffer" is just a C-style string. I dont
see how to malloc() the right amount of memory. It is easy if its just
the command line arguments because you can do an array and sizeof()
each argument.
Ultimately I would like to treat the "buffer" as a list and ask for
certain parameters.
Maybe a std::map is what I should use.
Here is an example:
the config file has:
---------------------
| -user joe
| -pwd football
|____________
run the program with additional cmd line args
C:\ prog -server 127.0.0.1 -port 999
the server, port, user, and pwd need to be in the "buffer". This is
why a map might work but could be overkill.
Thanks for any help,
31337one
Let me introduce myself. I would say that I am an intermediate
programmer in C++. I am studying comptuer science in college. However,
I have never had a formal introduction to buffers. Here is my problem:
I have a program that can have a config file and also command line
arguments.
When it executes I want to grab the command line arguements and stuff
them into a buffer (i think). Then i want to read everything from the
config file which is basically command line flags that are set and
stuff them into the buffer also.
The problem I am seeing is a "buffer" is just a C-style string. I dont
see how to malloc() the right amount of memory. It is easy if its just
the command line arguments because you can do an array and sizeof()
each argument.
Ultimately I would like to treat the "buffer" as a list and ask for
certain parameters.
Maybe a std::map is what I should use.
Here is an example:
the config file has:
---------------------
| -user joe
| -pwd football
|____________
run the program with additional cmd line args
C:\ prog -server 127.0.0.1 -port 999
the server, port, user, and pwd need to be in the "buffer". This is
why a map might work but could be overkill.
Thanks for any help,
31337one