Apmatrix error.

This is a discussion on Apmatrix error. within the C++ Programming forums, part of the General Programming Boards category; Hello, long time lurker first time poster. Anyway, I've been using apmatrix for a short time and I've run across ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    26

    Apmatrix error.

    Hello, long time lurker first time poster.

    Anyway, I've been using apmatrix for a short time and I've run across a problem.

    Anytime I choose to use

    board[row-1][col] = blahblah

    It works just fine. But when I add

    board[row+1][col] = blahblah

    I can compile it fine, but when I run the function to make it go row+1 it will just quit out, giving me an illegal matrix bounds(?) error. I'm pretty sure that means it does not go down one space, but it goes down until it is out of the matrix board, so that causes an error?

    ...Any ideas on how to fix this?

    btw I can show more code if you guys want.
    Last edited by two31d; 10-16-2005 at 01:45 AM.

  2. #2
    Registered User
    Join Date
    Oct 2005
    Posts
    26
    Alright if you can't help me with this, is there any other good 2d (X/Y axis) type of thing, I can use for C++?

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    6
    I'm VERY new to Cpp, so this is probably not gonna help. But hell, better safe than sorry.
    I think you first need to declare the array so it's big enough. And then use row++ or row--

    99% of me is thinking I should delete this post

  4. #4
    Moderately Rabid Decrypt's Avatar
    Join Date
    Feb 2005
    Location
    Milwaukee, WI, USA
    Posts
    300
    It sounds like you're trying to access part of the array that doesn't exist. If you declare:
    Code:
     int array[4];
    and later on try to access or assign a value to
    Code:
     array[anything over 3]
    you're going to have a problem because the only indexes for array that are valid are 0,1,2,3.

    If array has x indeces, and at the time the program hits this line:
    Code:
    board[row+1][col] = blahblah
    then if row >= x - 1, you're going to have trouble. Take a look at what the boundaries of your array are, and where row is when you hit that line in the code.
    There is a difference between tedious and difficult.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,442
    > is there any other good 2d (X/Y axis) type of thing, I can use for C++?
    Like a vector for example

    vector < vector < int > > myMatrix;

    I've no idea what an apmatrix is, but I guess it doesn't expand like a vector can do.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Oct 2005
    Posts
    26
    Yeah, APmatrix is a real iffy type of... well... matrix. Has a lot of problems with more than a few characters on the same line .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21