I'm doing a pretty tedious code that involves using 2d arrays, however I'm really not sure how to make the actual columns for the array, especially since they are character columns. The array is declared as a char but I'm confused if I need to declare the columns individually or use a loop. Does anyone know?
// Example program
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
char arr[8][8];
for(int k = 0; k < 8; k++){
for(int i = 0; i < 8; ++i){
arr[k][i] = 'a';
cout << arr[k][i] << " ";
}
}
return 0;
}
This is how you need to declare a two dimentional array of char.
Note: You do not have to do this! If you are interested, you can use this feature:
In c++ 11 and 14 you can you enumeration, which is an enum class, that is of type char, and you can write char variables inside.