calling function error (doesnt accept arrays)

csharp United States
  • 18 years ago

    Hi guys, I need help again please, I get an error, when I try to call a function in “main ( )”, because of arrays as input.


    You can see the code below and the message error, can anyone tell what I’m doing wrong??? I’m suspecting of pointers, or maybe the function should be something else than “int” maybe, just the array syntax as an argument when I call the function.



    define iROWS 12


    define iCOLUMNS 2



    int img[iROWS] [iCOLUMNS] = {
    0,10,
    10,20,
    20,30,
    30,40,
    40,50,
    50,60,
    60,50,
    50,40,
    40,30,
    30,20,
    20,10,
    10,0
    };



    int circ (int x, int y, int r, int *img [iROWS][iCOLUMNS])
    {

    }


    main(int argc, char* argv[])
    {


    int funcCirc, i;


    funcCirc = circ (6, 6, 5, 12, 12, img[12]);


    ////Error message that I get



    (...) : error C2664: 'circ' : cannot convert parameter 6 from 'int' to 'int *[]'
          Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    Error executing cl.exe.
    VarMed5.exe - 1 error(s), 0 warning(s)




    ///functional code inside the main function:
    for (i=0; i<iROWS; i++){
      printf ("linhas: %d  colunas: %d\n", img , img [iCOLUMNS]);
      getch ();
    }


    The call of the function doesn’t accept arrows (maybe multidimensional arrays)
    - I’m suspecting of pointers.
    - Or the function as int, maybe I should use void instead, or struct type.
    - Or it’s a syntax problem in the way I call and use multidimensional arrays as arguments  


    I’ve tried to use the array in the main function, that was initialized as global (outside any function), and it works perfectly. But not the function.


    All I know is that the function has to return a struct of arrays.


    Can anyone help? And check what’s wrong?


    Thanks a lot


    LMDG

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Perl - The only language that looks the same before and after RSA encryption.” - Keith Bostic