|
This[^] must help you.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
Hi, I am reading in a line from a .dat file using fgets. The line is an unknown number of variables written in scientific notation (4.20000e+00 1.00000e-01 1.177000e+00 0.000000e+00 ...). The first two are an x and y location and will always be there. Due to the number of these lines to read in, minimum is 500000, I don't want to use char/string as each number will take about double the memory of a float. Using sscanf with a large amount of %f I can find the number of variables (there may be up to 30).
int number = sscanf(data_in,"%f%f%f%f%f%f%f%f%f%f%f...",&temp[0],&temp[1],...,&temp[n]);
With number I can create a string with the correct number of '%f' and set the array to the correct length.
At the moment I use a full array of 30 with the correct number of %f. Knowing how many variables there are I can pull only the valid elements from the array.
I am stuck on how to set the number of references '&temp[n]', to match the number of %f in the format string.
Any ideas on how to set everything equal lengths would be greatly appreciated.
Jim
this thing looks like it was written by an epileptic ferret
Dave Kreskowiak
|
|
|
|
|
jimwawar wrote: I am stuck on how to set the number of references '&temp[n]', to match the number of %f in the format string.
How about
std::vector<double> numbers;
std::stringstream str;
str <<< data_in;
for ( unsigned i = 0; i < number_count; ++i) {
double d;
str >> d;
numbers.push_back( d);
}
You will end up with number_count doubles in the vector numbers .
You will need to improve the error checking, and you might want to use iterators here, if you feel fit.
Also, boost::lexical_cast[^] could be used to make this more programmer-friendly.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Thanks for the help.
Jim
this thing looks like it was written by an epileptic ferret
Dave Kreskowiak
|
|
|
|
|
What about using a loop?
int max = 30;
for( int n = 0; n < max; n++ )
{
sscanf( data_in, "%f", &temp[n] );
}
- NS -
|
|
|
|
|
Thanks for the help.
Jim
this thing looks like it was written by an epileptic ferret
Dave Kreskowiak
|
|
|
|
|
Welcome...
- NS -
|
|
|
|
|
CFile::GetStatus(filePath, fStatus) works fine with local files, but does NOT work with remote shared files when accessed by UNC.
Any ideas on how to access/read/write remote files from MFC C++ apps would be greatly appreciated?
Thanks in advance.
|
|
|
|
|
insignia wrote: CFile::GetStatus(filePath, fStatus) works fine with local files, but does NOT work with remote shared files when accessed by UNC.
Unless I misunderstood your question, this works fine for me:
CFileStatus stat;
CFile::GetStatus(_T("\\\\machine\\share\\boot.ini"), stat);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello All,
i am preparing a application in which i am using multiple group box which having multiple radio buttons and check boxes.
i want to use a group box of multiple radio button as a single control so i
please share your knowledge.
thanks
|
|
|
|
|
Put the tab order in the sequence.( to see the tab order take the dialog in the resource and press ctrl + D ).
|
|
|
|
|
...and start every group of button with the group property.
Tip: in resource view use Ctrl+T and Ctrl+D and look and click (to sort) :->
Greetings from Germany
|
|
|
|
|
As long as you put them in the proper z-order and use the WS_GROUP style correctly, this is how they are supposed to behave.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How do I put a BMP file that would display 32-bit worth of colors. The EVC++ seems to be lower the color specs of whatever image I pu on the dialog box., advice
Thanks,
Samuel
|
|
|
|
|
I have crated a MFC dialog which i coded as model dialog. what is easy way to convert it in to modeless dialog.
|
|
|
|
|
Bhavesh Bagadiya wrote: what is easy way to convert it in to modeless dialog.
use CDialog::Create() function or call the DoModal from another thread.
|
|
|
|
|
Bhavesh Bagadiya wrote:
what is easy way to convert it in to modeless dialog.
Naveen.R wrote: or call the DoModal from another thread.
Is it so easy?
- NS -
|
|
|
|
|
NS17 wrote: Is it so easy?
For me the Create will be more easy. but i just mentioned another option also..
|
|
|
|
|
Naveen.R wrote: For me the Create will be more easy
Mee too...
- NS -
|
|
|
|
|
i'm dispalying a set of strings in richedit which is in readonly mode...but after dispalying the cursor is not seen in the last letter...
it is in the firstline first column itself...
how to make the cursor move while the string is getting displayed successively and at the end cursor should be at the end of string....
any help with a code snippet....
thanx n advance...
|
|
|
|
|
m_richedit.SetSel( pos, pos );
- NS -
|
|
|
|
|
Try:
<br />
int i = m_RichLogCtrl.GetWindowTextLength();<br />
m_RichLogCtrl.SetSel(i, i);<br />
Best Wishes,
-David Delaune
|
|
|
|
|
Does anybody know how to obtain a unique ID number for:
1) Windows version running
2) HDD
3) Motherboard
4) Processor
I am coding in c++. Please do not include anwers referring to other languages.
|
|
|
|
|
Take a screwdriver, take away the side of your PC's case and look inside ( may need a torch for the last step ).
J_E_D_I wrote: Please do not include anwers referring to other languages.
|
|
|
|
|
WalderMort wrote: Take a screwdriver, take away the side of your PC's case and look inside ( may need a torch for the last step ).
Mmmm...what a comedian! I wish I could follow your advice but unfortunately I have a laptop and no torch is necessary.
Therefore we all hand it back to you, so you can make better use of it.
Harry Potter, could you please not waste our bytes, bandwidth and time?
|
|
|
|