Assigning typedef strings to typedef char arrays

So I'm in a college class, working on the last function on this lab.

We have to take a name that we read into a stateNameType element of an array, where the stateNameType is a char array of [14 + 1], as all the states are length of 14 with spaces.

so I create an array of "stateNameType decreasingStatePopulations[50]", and pass this into a function with a parameter of
stateNameType decreasingStatePopulations[] that finds two successive reported years where the population decreased.

I've tested the function, and the flag always works when testing the population decreases.
The only error i'm getting is actually assigning the state name to the new array of decreasingStatePopulations - when I try to assign decreasingStatePopulations[newArrayIndex] = stateInfo[stateIndex].stateName, it tells me the expression must be a modifiable lvalue. If i static cast the new array to a string, there are no compiler errors but the function itself doesn't pass the state name into the new array.

Example of the code (within another loop)

//Determine if two years of population decreased in a row for this state
if (twoYearsFound)
{
//The list of decreasing populations at state index is the state name at state index
decreasingStatePopulations[newArrayIndex] =
stateInfo[stateIndex].stateName;

//Increment the index of the new stateNameType array
newArrayIndex++;

//Initialize year index to 0 to end the loop
yearIndex = 0;
}

I got it working, using a strcpy_s function - forgot you can't assign char arrays with the = operand.
Topic archived. No new replies allowed.