Assigning values to character arrays inside of a structure array in C++
<p>I am new to C++, but very familiar with Python. Trivial tasks in Python seem to be much more complex in C++. I am attempting to make a simple game where a word in a foreign language is printed on screen, the user guesses the value, if correct they are awarded a point and continue guessing what the value of other numbers printed on screen are. The problem I am facing that for the course I am taking we are not allowed to use strings only character arrays. The reason for this has not been explained by the instructor.</p>

<p>In Python, I would create a tuple of strings for the foreign word numbers:</p>

<pre><code>foreignWords = ('een', 'twee', 'drie'....) 
</code></pre>

<p>index 0 would be the word for one in Dutch, index 1 would be the word for two in Dutch, etc. I would use a function to randomly select a number between 0 and the length of foreignWords, print it on screen, etc. Very simple to do.</p>

<p>I thought I could simply create a structure array and strcopy the char arrays into the struct array. </p>

<pre><code>    struct numbers
    {
      char numberWord[7];
    };


    int main()
    {
      numbers numberChoices[10];
      strcpy(numberChoices[0].numberWord, 'een');
      strcpy(numberChoices[1].numberWord, 'twee');
      strcpy(numberChoices[2].numberWord, 'drie');
      strcpy(numberChoices[3].numberWord, 'vier');
      strcpy(numberChoices[4].numberWord, 'vijf'):
      strcpy(numberChoices[5].numberWord, 'zes');

      etc.
</code></pre>

<p>That doesn't work though. It produces an error:</p>

<pre><code>    string.h:129:14: error:   initializing argument 2 of ‘char* strcpy(char*, const char*)’ [-fpermissive]
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
</code></pre>

<p>However, if I create a for-loop and input the char array via cin >> the structure array will store my entries and they can be called by index.</p>

<p>Essentially, what I would like to do is make an array of char arrays that way I can an index get the value back and trivially keep track of the numerical value of the word (numberChoices[i].numberWord, i+1 = numerical value of the printed word). I don't know if this appropriate approach or not, but I am trying to be efficient, because the structure array would be referenced quite a bit to read what is stored in memory, save that value to a new variable and manipulate the referenced char array by deleting characters randomly and having the user guess what value the printed words. </p>

<p>What is the correct way to go about making an array of char arrays where the char array elements are hard coded?</p>