Transpose matrix

This is a discussion on Transpose matrix within the C Programming forums, part of the General Programming Boards category; I'm currently having a problem with a program that is supposed to create the transpose of a 2-dimensional matrix. I ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    40

    Transpose matrix

    I'm currently having a problem with a program that is supposed to create the transpose of a 2-dimensional matrix.

    I have successfully assigned values to the first array, but I cannot get the values to assign to the second array.

    This is the piece of code that seems to be giving the problem:
    Code:
        for (l=0; l<3; ++l);
        {
            for(m=0; m<4; ++m);
            {
                arrayB[m][l]=arrayA[l][m];
                printf("[%d]", arrayB[m][l]);
            }
            printf("\n");
    It only prints one value, and it is not the value from the other array, any help would be greatly appreciated! Just let me know if you need to see the rest of the code.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Why don't you print out the value of arrayA[l][m] before you assign it to see if your source data is fine?


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,047
    Hint: both the for loops have a null body.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Do you see what I see?

    Code:
        for (l=0; l<3; ++l);
        {
            for(m=0; m<4; ++m);

  5. #5
    Registered User
    Join Date
    Dec 2009
    Posts
    40
    Fantastic, thank you

    Oh how I hate silly syntax errors!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C - access violation
    By uber in forum C Programming
    Replies: 2
    Last Post: 07-08-2009, 01:30 PM
  2. Matrix Help
    By HelpmeMark in forum C++ Programming
    Replies: 27
    Last Post: 03-06-2008, 04:57 PM
  3. Help with matrix transpose
    By sass208 in forum C Programming
    Replies: 6
    Last Post: 12-09-2006, 01:02 AM
  4. Matrix and vector operations on computers
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 05-11-2004, 06:36 AM

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