How to convert char** to char array
-
Hello, does anybody know how to convert char** to char array? here is my code
#include stdio.h splitString(char** aString) { char[10][10] localstring; ..... ..... ..... /* HERE I NEED TO CONVERT aString to localstring */ ..... } int main { char[10][10] arraystring; splitString(arraystring); return 0; }
ThanksIt is never late to learn
-
Hello, does anybody know how to convert char** to char array? here is my code
#include stdio.h splitString(char** aString) { char[10][10] localstring; ..... ..... ..... /* HERE I NEED TO CONVERT aString to localstring */ ..... } int main { char[10][10] arraystring; splitString(arraystring); return 0; }
ThanksIt is never late to learn
-
Hello, thanks for your reply. I think i can, here is what i did
memcpy(localstring,aString, sizeof(localstring));
But, I want localstring to point aString's address.It is easy if char *aString, then address of aString -> &aString, if it is char **aString, then address of aString -> ??????
that is the problem i dont know. How do we get aString's address? thanksIt is never late to learn
-
Hello, thanks for your reply. I think i can, here is what i did
memcpy(localstring,aString, sizeof(localstring));
But, I want localstring to point aString's address.It is easy if char *aString, then address of aString -> &aString, if it is char **aString, then address of aString -> ??????
that is the problem i dont know. How do we get aString's address? thanksIt is never late to learn
splitString(char localstring[][10]) { ..... ..... Is it acceptable?
-
splitString(char localstring[][10]) { ..... ..... Is it acceptable?
Hello, thanks for your reply. But it is not acceptable, Because sometimes i call splitString() function with char** parametr. thanks
It is never late to learn
-
Hello, thanks for your reply. I think i can, here is what i did
memcpy(localstring,aString, sizeof(localstring));
But, I want localstring to point aString's address.It is easy if char *aString, then address of aString -> &aString, if it is char **aString, then address of aString -> ??????
that is the problem i dont know. How do we get aString's address? thanksIt is never late to learn
Gofur Halmurat wrote:
How do we get aString's address?
Its address is the same (i.e.,
&aString
) no matter how many*
precede it. The address(es) it points to is a different matter altogether."Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Hello, thanks for your reply. But it is not acceptable, Because sometimes i call splitString() function with char** parametr. thanks
It is never late to learn
Gofur Halmurat wrote:
i call splitString() function with char** parametr.
with char**, you mean simply typecast type of multidimentional array of characters or array of pointers to array. Both cannot be interchanged. char aString[10][10] = {"Test1", "Test2", "Test3"}; char *aString2[10] = {"Test1", "Test2", "Test3"}; former uses contigious buffer while later stores pointers to some other location. So you have to be sure what kind of data the function expects. in your example any way you can type cast like this. char (*localString)[10][10]; localString = reinterpret_cast<char (*)[10][10]>(aString); note astring should be a multidimentional array as in your example. if you are really expecting the muldimensional array, restrict the user by using the array in function argument.