LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling Multiple mains

Darnell:

 

You made a reference earlier in this post about doing something "the book way".  What C reference book are you using?

 

Even with all the great references on the web, I still don't think they replace a good reference book.

 

If you tell me what book you're using, I will see if I can find a copy.  Then when future questions come up, I can point you to a specific reference in your book.

 

After I get a copy of your book, if I think it's weak on the basics, I may suggest another title.

Message 21 of 38
(1,913 Views)
C++  teach yourself  4th edition  Jesse liberty
0 Kudos
Message 22 of 38
(1,907 Views)

1>c:\documents and settings\z1083774\desktop\jjjj\jjjj\edd.cpp(21) : error C2059: syntax error : ']'

he's getting this error now

 

#include <stdio.h>



long f_ConvDblToSingleArray ( double *double_array[][1000], double *single_array[3000] , int max_index );
int main()
{
int q=4,u=1000;
double *temp_data[][1000] ={0};
double *conv_data[5][1000] ={0};

double *meas[3000] ={0};   


f_ConvDblToSingleArray( temp_data, meas, q );
f_ConvDblToSingleArray( conv_data, meas, q );




conv_data[q][u] = temp_data;//this gives me an error********************



return 0;
}



//Library Function...(This compiles...)
long f_ConvDblToSingleArray(double *double_array[][1000],double *single_array[3000] ,int max_index )
{

long error = 0;

int idx1 = 0;
int idx2 = 0;
int index = 0;

for (idx1=0; idx1 < max_index; idx1++)
{
for ( idx2=0; idx2 < max_index; idx2++ )
{
single_array[index++] = double_array[idx1][idx2];
}
}//

return 0;

}


0 Kudos
Message 23 of 38
(1,900 Views)

Darnell:

 

I told you earlier that you need to specify the number of rows in your array variable declaration.  Note the difference I specified between the array variable declaration (where you need to specify the number of rows) and the function parameter declaration (where you don't need to specify the number of rows).

 

Your statement 

   double *temp_data[][1000] ={0};

 

Should be

   double *temp_data[4][1000] ={0};

 

Also remember that I told you that what you are doing with the ={0} assignment is only setting the value of the first element in the array, not the entire array.

 

On to the line you flagged as an error.  That error message is not very helpful, but if you look at the data types of the two items in your assignment, you'll see what you are doing wrong.

 

   conv_data[q][u] = temp_data;


conv_data[q][u] is a pointer to a double.

temp_data is a pointer to an array of pointers to doubles.

 

What are you trying to do?

0 Kudos
Message 24 of 38
(1,897 Views)

im trying to take my time and look at it closely, alot of people are having this one issue for some reason. in C youcan do it, in C++ you cant.

 

 

i just tried in CVI and ran very fine, but  in c++ its not

0 Kudos
Message 25 of 38
(1,895 Views)

now im getting just  one

error

 

1>c:\documents and settings\z1083774\desktop\jjjj\jjjj\edd.cpp(21) : error C2106: '=' : left operand must be l-value
 

 

 

 

int main()
{
int q=4,u=1000;
double temp_data[][1000] ={0};
double conv_data[][1000] ={0};

double meas[4000] ={0};   


f_ConvDblToSingleArray( temp_data, meas, q ,u);
f_ConvDblToSingleArray( conv_data, meas, q ,u);




conv_data=temp_data;//this gives me an error



return 0;
}

0 Kudos
Message 26 of 38
(1,897 Views)

Darnell:

 

For the third time, you need to specify the number of rows in your array variable declaration.

 

Don't say

double temp_data[][1000] ={0};
double conv_data[][1000] ={0};

 

Say

double temp_data[5][1000] ={0};  // 5 or however many rows you need
double conv_data[5][1000] ={0};

 

What are you trying to do with the statement

conv_data=temp_data; // ????

 

conv_data is already a pointer to an array with its value set.  Based on the way you declared it, you can't just move by trying to assign a new value to it.  That's why the error message said that the left operand must be an L-value.  An L-value is an entity that can accept an assignment (on the Left hand side of an assignment statment).  Based on the way you declared conv_data, the pointer value for that array is constant, can't be changed, and is not a valid L-value.  An L-value must have an address so something can be written to it.  conv_data does not have an address, it is an address.

 

What are you trying to do with that statement?

 

And another thing: you still haven't addressed Roberto's concern about the way you are using max_index in your loop.  You are treating the multi-dimensional array as if it's square, but it's not.

 

So are you using arrays of doubles or arrays of pointers to doubles?  You keep jumping back and forth every time you post some code.

 

You need to figure out what you are doing.

 

0 Kudos
Message 27 of 38
(1,889 Views)

Darnell:

 

I didn't do a good job of keeping up with you changing back and forth between arrays of doubles and arrays of pointers to doubles.

 

I said

Your statement 

   double *temp_data[][1000] ={0};

 

Should be

   double *temp_data[4][1000] ={0};

 

But the assignment statement ={0} is wrong.  You are trying to assign an integer to a pointer to a double.

 

The statement should be

   double *temp_data[4][1000];

 

If you are using arrays of pointers.  Are you?

0 Kudos
Message 28 of 38
(1,884 Views)

Al,

  I need to buy you a beer some time just for your effort and lack of homocidal actions.

0 Kudos
Message 29 of 38
(1,881 Views)

scomack:

 

Thanks for the encouragement.  I guess it's a good thing that this forum is mostly anonymous.

0 Kudos
Message 30 of 38
(1,877 Views)