Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C - C++ Learning > Re: Using the s...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 22 of 22 Topic 4074 of 4370
Post > Topic >>

Re: Using the same source file from other source files

by Hal Vaughan <hal@[EMAIL PROTECTED] > Mar 20, 2008 at 08:34 PM

Ben Bacarisse wrote:

> Hal Vaughan <hal@[EMAIL PROTECTED]
> writes:
> 
>> Ben Bacarisse wrote:
>>> Hal Vaughan <hal@[EMAIL PROTECTED]
> writes:
> <snip>
>>>> Okay.  I'm a bit confused.  I have:
>>>>
>>>> int main(int argc, char* argv[])
>>>>
>>>> which leads me to believe argv is of type char*,
>>> 
>>> Ah, no. In C and C++, the [] in a parameter list act almost exactly
>>> like a *.  argv is and array of char pointers and thus becomes a
>>> pointer to a the first char pointer when it is passed to main.  The []
>>> form is transitional but a little confusing.
> <snip>
>> So now that I have
>>
>> map<string,string> parseargs(int count, char** args[])
>>
>> how do I access the individual char[] arrays in args (which is argv
being
>> passed to the function)?  I can't do:
>>
>>         string arg;
>>         arg = args[x]
>>
>> I've tried that and it doesn't work.  Do I need to dereference it or
>> something?
> 
> It should work once the parameter is correctly specified (see
> elsethread), though I prefer initialisation semantics to assignment
> where possible:
> 
>   string arg = args[x];

You're right.  It's working fine now.  Got it all switched over so I'm
using
make and I've taken care of getting read of any conflicting names and so
on.  I wrote up a simple Perl script that will scan my .c or .cpp files
and
create a .h file with a list of all the functions as prototypes.  It also
makes sure the .h file uses all the same includes the .c or .cpp file uses
and includes typedefs as well.  There's a few glitches, for instance if
you
define a map with:

map<string, string>

it won't get it unless you remove the space after the comma.  I'm sure I
could work that out, but the regex is messy enough as it is.  It makes it
easy for regenerating the .h files whenever I update the source files,
though.

Hal
 




 22 Posts in Topic:
Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 07:10:47 
Re: Using the same source file from other source files
Richard Heathfield <rj  2008-03-20 07:25:59 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 07:29:28 
Re: Using the same source file from other source files
"Jim Langston"   2008-03-20 00:55:37 
Re: Using the same source file from other source files
Philip Potter <pgp@[EM  2008-03-20 15:31:49 
Re: Using the same source file from other source files
Richard Heathfield <rj  2008-03-20 08:36:26 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 08:50:25 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 09:28:25 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 09:37:01 
Re: Using the same source file from other source files
"Chris ( Val )"  2008-03-21 03:37:07 
Re: Using the same source file from other source files
Philip Potter <pgp@[EM  2008-03-25 17:22:35 
Re: Using the same source file from other source files
Ben Bacarisse <ben.use  2008-03-20 15:08:23 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 15:37:26 
Re: Using the same source file from other source files
Ben Bacarisse <ben.use  2008-03-20 15:48:02 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 15:56:20 
Re: Using the same source file from other source files
Philip Potter <pgp@[EM  2008-03-20 17:11:20 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 17:54:57 
Re: Using the same source file from other source files
Philip Potter <pgp@[EM  2008-03-21 10:03:58 
Re: Using the same source file from other source files
Ben Bacarisse <ben.use  2008-03-20 19:34:41 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 20:31:21 
Re: Using the same source file from other source files
Ben Bacarisse <ben.use  2008-03-20 19:45:49 
Re: Using the same source file from other source files
Hal Vaughan <hal@[EMAI  2008-03-20 20:34:08 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 11:46:34 CST 2008.