Pass pointer to double array as func. parameter
-
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
-
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
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); -
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
The following explains the problem you're facing and some solutions: http://www.quepublishing.com/articles/article.asp?p=25281&rl=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
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) -
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
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 theinput
parameter is just a pointer. The usual way is to add a second parameter of typesize_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 -
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
Gentlemen, Thank-you for your assistance. Have it working now. :) All the best, Robert