Thread: Transpose of a 2 dimensional array

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    It's because the row and column have different dimensions, so when you swap matrix[r][c] with matrix[c][r], you're trying to put 10 elements where you only have room for 5.

    edit:
    I suppose I should tell you how to fix it too.

    I would use a 1-dimensional array with ROW*COL elements. Then you can subscript it with [r*COL+c]
    Last edited by NeonBlack; 04-29-2010 at 06:51 PM.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting 2 dimensional array to node structure
    By pawikan in forum C++ Programming
    Replies: 10
    Last Post: 12-02-2009, 04:19 AM
  2. two dimensional array
    By leisiminger in forum C Programming
    Replies: 12
    Last Post: 03-09-2008, 11:53 PM
  3. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 01:01 AM
  4. Replies: 5
    Last Post: 11-20-2001, 12:48 PM