How to change one row in a matrix using a loop?

Hello. I have the matrix below (3x3)which contains 9 names. How can I change one row in this matrix using a loop and set all names (of that row) to Pete? Thanks for any help.

string **firstArray = new string*[3];
for (int i = 0; i < 3; i++)
{ firstArray[i] = new string[3];}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <string>
using std::string;

int main (int argc, char* argv[])
{
        string** firstArray = new string*[3];
        for (int i=0; i<3; i++)
        {
                firstArray[i] = new string[3];
        }

        int i = 1; // this is the row you want to change, in this example the 2nd row
        string name = "Pete";
        for (int j=0; j<3; j++)
        {
                firstArray[i][j] = name;
        }
        return 0;
}
Thank you.
Topic archived. No new replies allowed.