Multiplication of C ++ arrays

0

I have a C ++ program that allows me to multiply 2 arrays, my problem is that I did not want to have to predefine the size of each array, so I used the following code:

    int ia, ib, ja, jb, ic, jc;
    float matriz_A[ia] [ja], matriz_B[ib][jb], matriz_C[ic][jc];

    printf("Escolheu input por TECLADO");
    printf("\n==========================");
    printf("\n\nLeitura de dados");
    printf("\n===================");
    printf("\n\nIndique o tipo de matriz que pretende inserir ['i' e 'j']");

But the code contains errors, how can I fix the problem?

Purpose: Have the user choose the 'i' and 'j' of each array. He wanted the matrix C to have the dimension ic and jc according to matrix A and B Thank you in advance.

    
asked by anonymous 10.05.2017 / 14:51

1 answer

0

In the first point, you are using the value of ia, ib, ja, jb, ic, jc variables before populating them. So they just have garbage and your program behaves erratically.

If you really want to test the program, initially I strongly recommend that you do not start with the interface in the middle of the tests. What do I mean by that? Let me explain better in the paragraph below.

So far, you have shown 7 lines of code, two of which are just variable declarations and the other 5 are interface messages. Of these 7 lines, it can be said that only the 2 of variable declaration are referring to your goal, but also do not bring you closer to it. You see, you have not even started multiplying arrays! You're still popping the data through the interface!

Leave it to interface at a later time, focus on your actual problem right away, and once it is resolved, you may worry about an interface to receive data.

    
10.05.2017 / 15:00