Thread: Matrix c program help!!!

  1. #16
    Registered User
    Join Date
    Feb 2009
    Posts
    12
    Quote Originally Posted by vart View Post
    Do you sometimes read the warning and error messages of the compiler?
    ya and it didn't give me any, i could just run it

  2. #17
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by kclew View Post
    ya and it didn't give me any, i could just run it
    But your problem is highly likely to be caused by the fact that the compiler doesn't know the dimensions of the array!

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #18
    Registered User
    Join Date
    Feb 2009
    Posts
    12
    Quote Originally Posted by matsp View Post
    But your problem is highly likely to be caused by the fact that the compiler doesn't know the dimensions of the array!

    --
    Mats
    but that is part of the my program, i'm supposed to input how many columns and rows into the function and from there it supposed to allow me to add and everything, which is not working

  4. #19
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by kclew View Post
    but that is part of the my program, i'm supposed to input how many columns and rows into the function and from there it supposed to allow me to add and everything, which is not working
    Yes, but if you are passing a 2D array to another function, you need to, one way or another, supply the size of all but the final dimension to the compiler. If you don't, it will not be able to do the math of multiplying the row-number by column-size, which it needs to do to find the data in a particular row/column pair.

    If you want it to be fully-flexible, then you need to find another way to pass your matrix pointer (e.g. pointer to pointer or do your own math to calculate the row/column position)

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #20
    Registered User
    Join Date
    Feb 2009
    Posts
    12
    so how should i approach this, my max matrix is 4 so i put that in the 2nd bracket, but it still gives me these off numbers

  6. #21
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by kclew View Post
    so how should i approach this, my max matrix is 4 so i put that in the 2nd bracket, but it still gives me these off numbers
    By second bracket, do you mean left or right? The one on the left is the one that needs to be sized.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #22
    Registered User
    Join Date
    Feb 2009
    Posts
    12
    i sized the one on the right, ill try switching it
    nope still gives me two single digit numbers and then some junk

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C program 2D matrix multiplication using malloc
    By college_kid in forum C Programming
    Replies: 5
    Last Post: 04-03-2009, 10:04 AM
  2. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  3. Weird errors.
    By Desolation in forum C++ Programming
    Replies: 20
    Last Post: 05-09-2007, 01:10 PM
  4. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  5. Replies: 1
    Last Post: 03-06-2006, 07:57 PM