string array

1
2
3
4
5
6
7
8
9
10
11
int num = 0;
char line[255];
char skillArray[SKILL_TOTAL];

while (num < SKILL_TOTAL)
{
   num++;
   snprintf(line, sizeof(line), "[%3d] %s", num, skillText[num]);
   skillArray[num] = line; // ERROR: a value of type "char *" cannot be assigned to an entity of type "char"
   printf("%s \r\n", line);
}


The above code, minus the "skillArray[num] = line;" part, works great. How can I get each of those lines stuffed into the skillArray[] array?

The reason I want to do this is so that I can perform sorting functions before I print them to the screen.
Use standard C function std::strcpy or std::strncpy declared in <cstring>
Thanks 'vlad' for the reply. Perhaps an example (using the above code) of what you mean?
This isn't working either:
1
2
3
string b = "";
b = line;
skillArray[num] = b.c_str(); // ERROR: a value of type "const char *" cannot be assigned to an entity of type "char" 
Here is an example

std::strcpy( skillArray[num], line );
Well Vlad, that gives me:

argument of type "char" is incompatible with parameter of type "char *"

Okay, I got it working now. No more issues.
It was my typo. I think that skillArray is an array of character arrays that is that skillArray[num] is a character array. So change to

std::strcpy( skillArray, line );
Nope, that won't work either. It's okay thought, because I've already figured it out. Thanks though!
Topic archived. No new replies allowed.