trouble with setw and 2D arrays

I'm having trouble printing 2D arrays in an aesthetically pleasing manner. When I use the code below, the first row doesn't line up properly with the rest of the rows. Am I using the setw command incorrectly or something? Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int myArray[10][10];
    
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            myArray[i][j]=10*i+j+1;
        }
    }
    
    
    for(int i=0;i<10;i++){
        
        for(int j=0;j<10;j++){
            cout<<setw(5)<<myArray[i][j];
        }
        cout<<endl;
    }
I would say it works just fine: http://ideone.com/TDSwAm

Perhaps you have some previous output that is messing things up.
That's all of the code that I have in main, but the first row isn't aligned properly. On my screen the first two ends about 8 spaces too early, scrunching everything up. I haven't had this trouble before, so I don't understand why it's doing that.
Topic archived. No new replies allowed.