pointer and cstring array

If I have a cstring array char *a[2]; how do I make a={"aA", "bB"} character by character. In another word first assign 'a' to the first character of the first element, 'A' to the second character of the first, '\0' to the third character, then do the same for "bB'.
closed account (D80DSL3A)
Not sure what you mean. cstring arrays would be arrays of type char, not arrays of type char*.
Given the array of pointers, shall we allocate an array of chars to each?
If so:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>

int main()
{
    char *a[2];
    a[0] = new char[3];
    a[0][0] = 'a'; a[0][1] = 'A'; a[0][2] = '\0';
    a[1] = new char[3];
    a[1][0] = 'b'; a[1][1] = 'B'; a[1][2] = '\0';

    std::cout << a[0] << "  " << a[1] << std::endl;

    delete [] a[0];
    delete [] a[1];

    return 0;
}
Well, I mean array of cstrings. If char a[12]="helloXworld" , then I want the array of cstrings(let's say it's b) to be {"hello", "world", (char *)0}. What I want to know is how to set the first character of the first elment of b to be 'h'(which is a[0]), and the second character of the first element of b to be 'e'( a[1]), and so on. Thank you for response!!
Topic archived. No new replies allowed.