how to merge two dimensional arrays?

Discussion in 'C' started by aj_thk, Dec 5, 2015.

  1. aj_thk

    aj_thk New Member

    Joined:
    Dec 5, 2015
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
    
    
    
    
        int A[3][2]={{1,2},
                          {4,5},
                          {7,8}};
                          
        int B[3][1]=
                          {{0},
                          {4,},
                          {7,}};
    
    
    
    i want to merge array A and B into a single array C ,which should appear like

    int C= 0 1 2
    4 4 5
    7 7 8

    please help me with C code to this problem.
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    There's no single function that'll do this for you. You'll have to define C as int[3][3] then copy the members of A and B over one by one.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice