Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. functions with 2d array argument

functions with 2d array argument

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structureshelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adnan Merter
    wrote on last edited by
    #1

    i am new on c++ i need to create a function with 2d array argument. i mean i can use the integer numbers in a 2d array in my function. And i also need to know how i can copy the information from the textboxes to a 2d array in vc++. i hope you will help me. thanks

    CPalliniC 1 Reply Last reply
    0
    • A Adnan Merter

      i am new on c++ i need to create a function with 2d array argument. i mean i can use the integer numbers in a 2d array in my function. And i also need to know how i can copy the information from the textboxes to a 2d array in vc++. i hope you will help me. thanks

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      Adnan Merter wrote:

      need to create a function with 2d array argument. i mean i can use the integer numbers in a 2d array in my function.

      for instance

      int f(int a[3][2])
      {
      int i,j;
      for(i=0; i<3; i++)
      for(j=0; j<2; j++)
      printf("a[%d][%d]=%d\n", i, j, a[i][j]);
      return 0;
      }

      Adnan Merter wrote:

      And i also need to know how i can copy the information from the textboxes to a 2d array in vc++.

      What is your difficulty about? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

      In testa che avete, signor di Ceprano?

      A 1 Reply Last reply
      0
      • CPalliniC CPallini

        Adnan Merter wrote:

        need to create a function with 2d array argument. i mean i can use the integer numbers in a 2d array in my function.

        for instance

        int f(int a[3][2])
        {
        int i,j;
        for(i=0; i<3; i++)
        for(j=0; j<2; j++)
        printf("a[%d][%d]=%d\n", i, j, a[i][j]);
        return 0;
        }

        Adnan Merter wrote:

        And i also need to know how i can copy the information from the textboxes to a 2d array in vc++.

        What is your difficulty about? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

        A Offline
        A Offline
        Adnan Merter
        wrote on last edited by
        #3

        i have an array like x[5][5] and i need to use it as an argument in my function i know how i use 1d array. i can it by using pointers. void display (int *p, int size) { int i; for (i = 0; i < size; ++i) printf("%-5d%-5d \n", p[i],&p[i]); } int main() { int a[5] = {3, 8, 7, 6, 10}; display(a, 5); return 0; } but i dont know how ican use 2d arrays

        CPalliniC 1 Reply Last reply
        0
        • A Adnan Merter

          i have an array like x[5][5] and i need to use it as an argument in my function i know how i use 1d array. i can it by using pointers. void display (int *p, int size) { int i; for (i = 0; i < size; ++i) printf("%-5d%-5d \n", p[i],&p[i]); } int main() { int a[5] = {3, 8, 7, 6, 10}; display(a, 5); return 0; } but i dont know how ican use 2d arrays

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          For instance:

          void display (int *p, int size0, int size1)
          {
          int i, j;

          for (i = 0; i < size0; i++)
          for (j = 0; j< size1; j++, p++)
          printf("%-5d \n", *p );
          }

          int main()
          {
          int a[2][5] = {{3, 8, 7, 6, 10}, {6, 16, 14, 12, 20}};
          display((int *)a, 2, 5);
          }

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups