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. Pass pointer to double array as func. parameter

Pass pointer to double array as func. parameter

Scheduled Pinned Locked Moved C / C++ / MFC
csharpdatabasevisual-studiodata-structureshelp
6 Posts 4 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.
  • R Offline
    R Offline
    Robert Palma Jr
    wrote on last edited by
    #1

    I'm having trouble figuring out how to pass a pointer to a double array (1 dimensional) to a C function. Declaring array as: double xx[100]; Declaring func. int process( double *input[] ) Calling func. as one of the following: process ( xx ); process ( &xx[0] ); I get various "can't convert, can't recast" error messages from the compiler. I have also tried declaring a double pointer and pointing address of index zero of the array to the double pointer - no luck either. Using Visual Studio/Visual C 6.0 Many thanks, Robert

    T D M R 5 Replies Last reply
    0
    • R Robert Palma Jr

      I'm having trouble figuring out how to pass a pointer to a double array (1 dimensional) to a C function. Declaring array as: double xx[100]; Declaring func. int process( double *input[] ) Calling func. as one of the following: process ( xx ); process ( &xx[0] ); I get various "can't convert, can't recast" error messages from the compiler. I have also tried declaring a double pointer and pointing address of index zero of the array to the double pointer - no luck either. Using Visual Studio/Visual C 6.0 Many thanks, Robert

      T Offline
      T Offline
      Tom Archer
      wrote on last edited by
      #2

      int process(double *input)

      double xx[100];
      xx[0] = 1.1;
      xx[1] = 2.2;
      xx[2] = 3.3;
      xx[3] = 4.4;
      ...
      process(xx);

      1 Reply Last reply
      0
      • R Robert Palma Jr

        I'm having trouble figuring out how to pass a pointer to a double array (1 dimensional) to a C function. Declaring array as: double xx[100]; Declaring func. int process( double *input[] ) Calling func. as one of the following: process ( xx ); process ( &xx[0] ); I get various "can't convert, can't recast" error messages from the compiler. I have also tried declaring a double pointer and pointing address of index zero of the array to the double pointer - no luck either. Using Visual Studio/Visual C 6.0 Many thanks, Robert

        T Offline
        T Offline
        Tom Archer
        wrote on last edited by
        #3

        The following explains the problem you're facing and some solutions: http://www.quepublishing.com/articles/article.asp?p=25281&rl=1[^]

        1 Reply Last reply
        0
        • R Robert Palma Jr

          I'm having trouble figuring out how to pass a pointer to a double array (1 dimensional) to a C function. Declaring array as: double xx[100]; Declaring func. int process( double *input[] ) Calling func. as one of the following: process ( xx ); process ( &xx[0] ); I get various "can't convert, can't recast" error messages from the compiler. I have also tried declaring a double pointer and pointing address of index zero of the array to the double pointer - no luck either. Using Visual Studio/Visual C 6.0 Many thanks, Robert

          D Offline
          D Offline
          Dominik Reichl
          wrote on last edited by
          #4
          Declaring array as: double xx[100];
          Declaring func. int process( double *input[] )
          

          The second one is a double pointer (pointer to an array). So, pass your array like: process(&xx); Best regards Dominik


          _outp(0x64, 0xAD); and __asm mov al, 0xAD __asm out 0x64, al do the same... but what do they do?? ;) (doesn't work on NT)

          1 Reply Last reply
          0
          • R Robert Palma Jr

            I'm having trouble figuring out how to pass a pointer to a double array (1 dimensional) to a C function. Declaring array as: double xx[100]; Declaring func. int process( double *input[] ) Calling func. as one of the following: process ( xx ); process ( &xx[0] ); I get various "can't convert, can't recast" error messages from the compiler. I have also tried declaring a double pointer and pointing address of index zero of the array to the double pointer - no luck either. Using Visual Studio/Visual C 6.0 Many thanks, Robert

            M Offline
            M Offline
            Michael Dunn
            wrote on last edited by
            #5

            You can write either of these in the function:

            int process ( double* input );
            int process ( double input[] );

            The two are equivalent, and the equivalence is an artifact of C's predecessor languages. Note that you also need a way to tell process() the size of the array, because the input parameter is just a pointer. The usual way is to add a second parameter of type size_t where you pass the number of elements in the array. --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD

            1 Reply Last reply
            0
            • R Robert Palma Jr

              I'm having trouble figuring out how to pass a pointer to a double array (1 dimensional) to a C function. Declaring array as: double xx[100]; Declaring func. int process( double *input[] ) Calling func. as one of the following: process ( xx ); process ( &xx[0] ); I get various "can't convert, can't recast" error messages from the compiler. I have also tried declaring a double pointer and pointing address of index zero of the array to the double pointer - no luck either. Using Visual Studio/Visual C 6.0 Many thanks, Robert

              R Offline
              R Offline
              Robert Palma Jr
              wrote on last edited by
              #6

              Gentlemen, Thank-you for your assistance. Have it working now. :) All the best, Robert

              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