T O P I C R E V I E W |
eprlab |
Posted - 08/27/2003 : 3:14:25 PM I am using an array (float fit[4096]) in my Origin C code. I also pass this array to a few functions. I noticed that the array does not store the resultant values. Is it because I should be passing a vector to a function?
Also, I use many more arrays similar to the one above. Though I do not get any compilation errors, I am not sure about the usage with such a declaration.
EPR |
1 L A T E S T R E P L I E S (Newest First) |
cpyang |
Posted - 08/27/2003 : 3:57:53 PM Array should work, need to see code example to see what can be wrong. It is much better to use vector, as it can be resized and you can directly do vector arithmetics on vectors, like
void my_add_func(vector<float>& vv, double factor) { // just some calculation for(int ii = 0; ii < vv.GetSize(); ii++) vv[ii] += factor + 0.01 * ii; }
void main() { vector<float> fit(4096); fit = 0;// set all 4096 elements to 0;
my_add_func(fit, 10); printf("1st val = %f, last val = %f\n", fit[0], fit[4095]); }
CP
|
|
|