How to populate an array of char* pointer dymanically? - c++

This is a discussion on How to populate an array of char* pointer dymanically? - c++ ; <silverburgh.meryl@> wrote in message ... > On Jun 11, 1:55 pm, "BobR" wrote: > > ... additional ... > >[snip] > > Learn to use std::string..... > > Now look how easy it is with std:string... > > > > ...

+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 21

How to populate an array of char* pointer dymanically?

  1. Default Re: How to populate an array of char* pointer dymanically?


    <silverburgh.meryl@> wrote in message ...
    > On Jun 11, 1:55 pm, "BobR" wrote:
    > > ... additional ...
    > >[snip]
    > > Learn to use std::string.....
    > > Now look how easy it is with std:string...
    > >
    > > > #include <iostream>
    > > > #include <vector>
    > > > #include <ostream>

    > > #include <string>
    > >
    > > void FillVector( std::vector< std::string > &vec){ // non-const here
    > > vec.push_back( "abc" );
    > > vec.push_back( "def" );
    > > vec.push_back( "dummy" );
    > > return;
    > > } // FillVector(vector<string>&)
    > >
    > > void PrintVector( std::vector< std::string > const &vec,
    > > std:stream &out ){
    > > for( std::size_t i(0); i < vec.size(); ++i ){ // vector has the

    size
    > > out<<vec.at( i )<<std::endl;
    > > // out<<vec.[ i ]<<std::endl; // ok here, index is safe
    > > } // for(i)
    > > return;
    > > } // PrintVector(vector<string>const&,ostream &)
    > >
    > > > int main(){ using std::cout; // for NG post

    > > std::vector< std::string > MyVec;
    > > FillVector( MyVec );
    > > PrintVector( MyVec, cout );
    > > > return 0;
    > > > } // main()

    > >
    > > POVrookie


    > Bob,


    Please do not quote sigs (the '--'), it messes with some newsreaders.
    Thanks.

    >
    > Thank you very much for your help. i have one more question:
    > void FillVector( std::vector< std::string > &vec){
    > vec.push_back( "abc" );
    > vec.push_back( "def" );
    > vec.push_back( "dummy" );
    > }
    >
    > Where does these string "abc", "def", "dummy" allocated? Stack or
    > heap?


    It's copied directly[1] into the string in the vector. As long as the vector
    is alive, the strings are alive. You can modify the strings in the vector:

    // using the 'vec' in 'FillVector()' function
    vec.at( 1 ) = "Hello";
    vec.at( 1 ) += "World!";
    std::string tmp(" I want to be the leader of the ");
    vec.at( 0 ) = tmp;
    vec.at( 0 ) += "World!";
    if( vec.at( 2 ).size() < 10 ){
    vec.at( 2 ) = std::string( 20, '*' );
    }
    .... etc.


    > And do i need to call destructor for those strings?


    No. When the vector gets destructed, it calls the destructors of all the
    elements in it. Neat, eh? No messing with new/delete, etc., the string
    handles it's data, and the vector handles it's data ( the strings).

    [1] - it's a little more complex than that, but, for now, that's all you
    need.
    --
    Bob R
    POVrookie



  2. Default Re: How to populate an array of char* pointer dymanically?

    BobR <removeBadBobR@worldnet.att.net> wrote:
    > Please do not quote sigs (the '--'), it messes with some newsreaders.


    It should be "-- \n" (note the space before the newline). As such, your
    sig delimiter is missing the space.

    --
    Marcus Kwok
    Replace 'invalid' with 'net' to reply

  3. Default Re: How to populate an array of char* pointer dymanically?


    Marcus Kwok <ricecake@gehennom.invalid> wrote in message...
    > BobR <removeBadBobR@worldnet.att.net> wrote:
    > > Please do not quote sigs (the '--'), it messes with some newsreaders.

    >
    > It should be "-- \n" (note the space before the newline). As such, your
    > sig delimiter is missing the space.


    Ya know, I've never had any trouble with 'sig quoting', either on windows or
    GNU/Linux mail/newsreaders. I was told not to put 'code' below my sig, as it
    doesn't show in some readers ( it was some joke code).
    But, WHAT newsreader(s)? If it's just one single newsreader, shouldn't the
    distributor be contacted to correct it, instead of us asking posters not to
    quote sigs?

    OK, rant over.
    Thanks for the correction.

    --
    Bob R
    POVrookie



  4. Default Re: How to populate an array of char* pointer dymanically?

    BobR <removeBadBobR@worldnet.att.net> wrote:
    > Marcus Kwok <ricecake@gehennom.invalid> wrote in message...
    >> BobR <removeBadBobR@worldnet.att.net> wrote:
    >> > Please do not quote sigs (the '--'), it messes with some newsreaders.

    >>
    >> It should be "-- \n" (note the space before the newline). As such, your
    >> sig delimiter is missing the space.

    >
    > Ya know, I've never had any trouble with 'sig quoting', either on windows or
    > GNU/Linux mail/newsreaders.


    When the sig is properly delimited, my newsreader (tin) will
    automatically strip the sig before I reply.

    It seems you are using Outlook Express, which will strip blank spaces at
    the ends of lines, and thus corrupt your sig delimiter. I do not know
    if it has the option to turn this off.

    --
    Marcus Kwok
    Replace 'invalid' with 'net' to reply

  5. Default Re: How to populate an array of char* pointer dymanically?


    Marcus Kwok <ricecake@gehennom.invalid> wrote in message ...
    > BobR <removeBadBobR@worldnet.att.net> wrote:
    > > Ya know, I've never had any trouble with 'sig quoting', either on

    windows or
    > > GNU/Linux mail/newsreaders.

    >
    > When the sig is properly delimited, my newsreader (tin) will
    > automatically strip the sig before I reply.
    >
    > It seems you are using Outlook Express,


    correction - I'm using an *old* OE. <G>

    > which will strip blank spaces at
    > the ends of lines, and thus corrupt your sig delimiter. I do not know
    > if it has the option to turn this off.


    Have not found one (.. but, I didn't really look for it.).

    OE does what I need, except it puts 'PGP' signed stuff as an attachment (in
    some NGs), just a blank body. ;-{

    --
    Bob R
    POVrookie



  6. Default Re: [OT] How to populate an array of char* pointer dymanically?

    BobR wrote:
    > Marcus Kwok <ricecake@gehennom.invalid> wrote in message ...
    >> BobR <removeBadBobR@worldnet.att.net> wrote:
    >>> Ya know, I've never had any trouble with 'sig quoting', either on

    > windows or
    >>> GNU/Linux mail/newsreaders.

    >> When the sig is properly delimited, my newsreader (tin) will
    >> automatically strip the sig before I reply.
    >>
    >> It seems you are using Outlook Express,

    >
    > correction - I'm using an *old* OE. <G>


    Oh yeah. Why?

    >> which will strip blank spaces at
    >> the ends of lines, and thus corrupt your sig delimiter. I do not know
    >> if it has the option to turn this off.

    >
    > Have not found one (.. but, I didn't really look for it.).
    >
    > OE does what I need, except it puts 'PGP' signed stuff as an attachment (in
    > some NGs), just a blank body. ;-{


    There are people who call OE a newsreader.
    There are also people who use macros and call them templates :-)

    --
    Thomas
    http://www.netmeister.org/news/learn2quote.html

  7. Default Re: [OT] How to populate an array of char* pointer dymanically?


    Thomas J. Gritzan <Phygon_ANTISPAM@gmx.de> wrote in message...
    > BobR wrote:
    > > Marcus Kwok <ricecake@gehennom.invalid> wrote in message ...
    > >> It seems you are using Outlook Express,

    > >
    > > correction - I'm using an *old* OE. <G>

    >
    > Oh yeah. Why?


    Using win98se.
    ( ...and NO, I will not PAY for any newer ms products. Go GNU! )

    >
    > There are people who call OE a newsreader.


    Did I do that? I'll have to go wash my mouth out with soap.

    > There are also people who use macros and call them templates :-)


    Not me, I hate macros[1]! <G>

    [1] - other than include-guards, or compile 'directives' (#if, #else,
    #endif).
    --
    Bob R
    POVrookie



  8. Default Re: How to populate an array of char* pointer dymanically?

    On Jun 12, 4:38 pm, ricec...@gehennom.invalid (Marcus Kwok) wrote:
    > BobR <removeBadB...@worldnet.att.net> wrote:
    > > Please do not quote sigs (the '--'), it messes with some newsreaders.


    > It should be "-- \n" (note the space before the newline). As
    > such, your sig delimiter is missing the space.


    Note that Google messes this up sometimes. I've tried on my own
    postings: the space is present in the message as it appears, but
    when you hit the reply button, it gets stripped, and the sig
    remains.

    IMHO, this is (or should not be) a major problem. You edit the
    posting you are replying to anyway, to remove the unnecessary
    parts. The sig is just one more unnecessary part which needs
    removing.

    --
    James Kanze (GABI Software, from CAI) email:james.kanze@
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34



  9. Default Re: How to populate an array of char* pointer dymanically?

    James Kanze <james.kanze@> wrote:
    > On Jun 12, 4:38 pm, ricec...@gehennom.invalid (Marcus Kwok) wrote:
    >> BobR <removeBadB...@worldnet.att.net> wrote:
    >> > Please do not quote sigs (the '--'), it messes with some newsreaders.

    >
    >> It should be "-- \n" (note the space before the newline). As
    >> such, your sig delimiter is missing the space.

    >
    > Note that Google messes this up sometimes. I've tried on my own
    > postings: the space is present in the message as it appears, but
    > when you hit the reply button, it gets stripped, and the sig
    > remains.


    Yes, I've seen your posts about it in the past and I know you've
    earnestly tried very hard to figure out where the problem is. It is
    unfortunate that Google gets this wrong (if it is indeed caused by the
    Google chain of posting).

    --
    Marcus Kwok
    Replace 'invalid' with 'net' to reply

  10. Default Re: [OT] How to populate an array of char* pointer dymanically?

    BobR wrote:
    > Thomas J. Gritzan <Phygon_ANTISPAM@gmx.de> wrote in message...
    >> There are people who call OE a newsreader.

    >
    > Did I do that? I'll have to go wash my mouth out with soap.


    No, but why using it then?
    I switched from OE to Thunderbird some time ago and I found that they are
    used quite equally. But without the bugs.

    >> There are also people who use macros and call them templates :-)

    >
    > Not me, I hate macros[1]! <G>


    I was refering to another thread about "C++ templates" and "macro templates".

    > [1] - other than include-guards, or compile 'directives' (#if, #else,
    > #endif).


    Valid usage.

    > --
    > Bob R
    > POVrookie


    Your signature delimiter is broken, too.

    --
    Thomas
    http://www.netmeister.org/news/learn2quote.html

+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast

Similar Threads

  1. Populate an Array with DB records
    By Application Development in forum DOTNET
    Replies: 3
    Last Post: 11-09-2007, 03:01 PM
  2. Re: char pointer in a stucture for dll
    By Application Development in forum labview
    Replies: 0
    Last Post: 10-04-2007, 01:40 PM
  3. Convert int array to char array
    By Application Development in forum C
    Replies: 8
    Last Post: 09-27-2007, 06:08 AM
  4. difference b/w char arr[], & char *pointer
    By Application Development in forum c++
    Replies: 5
    Last Post: 06-10-2007, 05:37 PM
  5. pointer to char vs. char array - difference?
    By Application Development in forum c++
    Replies: 8
    Last Post: 02-27-2007, 07:35 PM