-
char **
I'm trying to make an array of character strings and i'm not sure how to do
it. I'm thinking I define a char** but then how do I allocate space or access
it once it has been created. Thanks.
-
Re: char **
you really don't want to get into this trouble. Why not use an array of
real string objects, e.g.,
#include <string>
std::string sarr[10];
Danny
Joe wrote:
>
> I'm trying to make an array of character strings and i'm not sure how to do
> it. I'm thinking I define a char** but then how do I allocate space or access
> it once it has been created. Thanks.
-
Re: char **
"Joe" <protoplasm@geocities.com> wrote:
>
>I'm trying to make an array of character strings and i'm not sure how to
do
>it. I'm thinking I define a char** but then how do I allocate space or
access
>it once it has been created. Thanks.
You probably want to do what the other guy said but i'll oblige. First
you need to allocate an array of char*'s or the array that will hold the
strings. Then you allocate space for each string. I don't know what your
input is going to be like but something like this.
char** notsogoodidea (int number, int strsize)
{
char **p = new char*[number];
if (!p)
return null;
for (int i = 0; i < number; i++)
p[i] = new char[strsize];
return p;
}
no guarantees that this will work. I just spent a term coding in an
obscure lisp based language and i havent't ouched C++ in a while.
Good luck. Just remember to deallocate everything.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|