#include <iostream>
#include <string>
#include <cstdlib>
usingnamespace std;
constint r = 4;
constint c = 4;
void showStars (string [r][c]);
int main() {
string stars[r][c];
showStars(stars);
return 0;
}
void showStars (string stars [r][c])
{
stars[r][c] = {"*"}; // works when I change r and c to 3.
for (int i = 0; i < r; i++){
for (int j = 0; j < c; j++)
cout << stars[i][j] << "\t"; //works when I change i and j to 3; idk why.
}
cout << endl;
}
Initialize your array at line ten with what you want '*' , remove line seventeen . That's all you need
The reason you get nothing in print is because in the declaration on line 10, your array is default intialized to empty strings "" , if you print that you get nothing . Solution to this is to intialize your array to * in the range r, c .