Here's my code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int steve[2][3] = {{2, 3, 4}, {8, 9, 10}};
//What the array will look like:
// 2, 3, 4,
// 8, 9, 10
//They operate like coordinates: array[row number][index of element within row]
//cout << steve[row][column];
int n = 0;
int i = 0;
//my way
while (n == 0 && i < 3)
{
cout << steve[n][i] << setw(2);
i++;
if (i == 3)
{
cout << endl;
i = 0;
n +=1;
while (n == 1 && i<3)
{
cout << steve[n][i] << setw(2);
i++;
}
}
}
}
My issue is my output looks like this:
2 3 4
8 910
When I'm trying to get it to look like this:
2 3 4
8 9 10
Can someone please explain to me why setw() is not working, and what it is actually doing to my code? Just a head's up, I already tried simply using spaces on both output commands, like this:
cout << steve[n][i] << " ";
cout << steve[i][n] << " ";
And it works the way I want it to, but I would really like to know how setw() works and why it is giving me this problem.
Thanks.