Re: passing a string to a C++ function
- From: "Leo" <none@xxxxxxxx>
- Date: Wed, 5 Oct 2005 13:06:56 -0400
Hmm...thanks for a very unhelpful answer.
let me rephrase it:
char items[3]={"tom","***","harry"}
does that satisfy your "remaining 3 pointers fixation"?
now onto the next:
Forget the above,
if I have a string with "tom","***","harry"
can I build an array with them?
(I will learn more about pointers when I have some time. FOr now all I need
is a very simple function. Either you can help me with some code, or leave
the preaching for another time. Sorry to be so blunt, but I am getting all
kinds of answers, yet none related to what I am asking for).
"David Webber" <dave@xxxxxxxxxxxxxxxxxxx> wrote in message
news:uXx2idcyFHA.3812@xxxxxxxxxxxxxxxxxxxxxxx
>
> "Leo" <none@xxxxxxxx> wrote in message
> news:%23tT%23VRcyFHA.596@xxxxxxxxxxxxxxxxxxxxxxx
>
> > 'items' is not an array pointer. It's a pointer array.
> > -- Ok!
> >
> > my point was not how I am DECLARING the array. My question was:
> >
> > passing a bunch of items to the function that will put them into
> > this array.
>
> You can't. You really *do* need to learn what pointers are.
>
> The statement
>
> char *items[6]={"tom","paul","joseph"};
>
> declares six pointers each to a char. It also initialises some
> memory with the strings and sets the first three pointers to point
> to them. The rmaining three pointers are just pointers that point
> nowhere in particular.
>
> > so passing item1, item2, item3 and store them into the items[]
> > array.
>
> You can't store anything in the items array except pointers. And
> when you leave the function they will go out of scope, and be lost,
>
> >...
> > Any thoughts?
>
> Yes. Learn C or C++. Learn what a pointer is, and what an array
> is, and their relationship. Think about what is stored in memory
> where, and how you get access to it, rather than creating invalid
> pointers. I'm sorry but you have to do this - there is no
> shortcut.
>
> Dave
> --
> David Webber
> Author MOZART the music processor for Windows -
> http://www.mozart.co.uk
> For discussion/support see
> http://www.mozart.co.uk/mzusers/mailinglist.htm
>
>
>
.
- Follow-Ups:
- Re: passing a string to a C++ function
- From: David Webber
- Re: passing a string to a C++ function
- From: red floyd
- Re: passing a string to a C++ function
- References:
- passing a string to a C++ function
- From: Leo
- Re: passing a string to a C++ function
- From: Victor Bazarov
- Re: passing a string to a C++ function
- From: Leo
- Re: passing a string to a C++ function
- From: David Webber
- passing a string to a C++ function
- Prev by Date: Re: wcscoll bug?
- Next by Date: Re: LNK2019 error
- Previous by thread: Re: passing a string to a C++ function
- Next by thread: Re: passing a string to a C++ function
- Index(es):
Loading