|
-
February 1st, 2013, 07:37 AM
#15
Re: Getting data in to C++ from excel, any help would be greatly appreciated
 Originally Posted by 2kaud
I also note in your code that you are not pre-reserving space for the vectors. If a vector does not have enough memory to store an extra element then it will re-allocate memory and copy existing elements into the new space when the extra element is added. If a vector has many elements added then this will take time. To avoid this reallocation initial space can be reserved. From my previous example, if it is expected that the result vector has, say, 5000 elements then memory for these can be pre-allocated
Code:
vector<results> resultsarray;
resultsarray.reserve(5000);
This means that memory re-allocation will now only occur if more than 5000 elements are stored in the vector.
Your previous code for export to csv file worked a treat, ty very much.
I am getting a few bizarre results though:
With this part of the code:
Code:
float t = ( y / z );
if (y==0){y = 1;}
if (z==0){z = 1;}
if ( t > 3 && y > 20 )
When i set t > 2 and y > 10, it works fine. And i see i get results where t is also > 3 and y > 20.
So i reset it to t > 3 & y > 20, to reduce the number of results. As i know there are results with these. But the programme closes without finishing. I presume cause results is empty. So it fails.
Any suggestions?
Rgds
Surreall
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|