|
lolici wrote: I am trying to use a CMFCEditBrowseCtrl button (in CFeaturesDialog class) to read numbers...
e.g. if there 2 numbers in text file I open with CMFCEditBrowseCtrl... The CMFCEditBrowseCtrl class does not open files. That class is simply an editable text box that optionally contains a browse button.
Are the numbers in the source file (comma) delimited, or one per line? Since I do not know the answer to either of this, I will error on the side of the latter, something like:
CStdioFile fileSource("source.txt", CFile::modeRead);
CStdioFile fileDest;
CString strLine;
CString strFile;
int num = 1;
while (file.ReadString(strLine))
{
strFile.Format("over%d.txt", num++);
fileDest.Open(strFile, CFile::modeWrite);
fileDest.WriteString(strLine);
fileDest.Close();
}
fileSource.Close();
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Do I have to include the text file (source.txt) in project?? Cause I got the message "source.txt file not found". The content of the file can change any time by any user is that a problem??
|
|
|
|
|
lolici wrote: Do I have to include the text file (source.txt) in project?? That's the name of the file you would retrieve from CMFCEditBrowseCtrl .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
The code you wrote above must be written in class void CDataDialog::OnBnClickedOk() ?Cause I have declare this class in a different dialog. I'm sorry for asking again, I got a little bit confused.
|
|
|
|
|
Where is the code to read the original file, and where do you store the two numbers? Once you have the numbers then writing them to their separate files is quite straightforward. It would be better if you generate the output file names dynamically, rather than hard coding them. It is also better to not use the W suffixes on Windows API calls; let the compiler generate the correct names based on your project settings.
|
|
|
|
|
This is a simplified version of the problem.
We have an array of numbers (between 0 and X-1), at each round, we choose a range of numbers that we compare and only promote the biggest one and eliminate the rest. At each round, we need to output the *original* indices of the numbers that have been eliminated.
This is best explained using an example:
Here is the input:
8
4
1 0 3 6 2 4 7 5
1 3
2 4
1 3
0 1
Output: 4 lines, the original index of the losers at each round
1 2
4 5
3 7
0
Here is a diagram of how the output was obtained, `[]` means the numbers inside the brackets are the ones being compared.
1 [0 3 6] 2 4 7 5
1 6 [2 4 7] 5
1 [6 7 5]
[1 7]
7
The basic idea is that we want to output the original indices of the number eliminated at each round.
**Approach:**
Model each number as a pair, with the second entry representing the original index. So we have the following:
(1,0) [(0,1) (3,2) (6,3)] (2,4) (4,5) (7,6) (5,7)
(1,0) (6,3) [(2,4) (4,5) (7,6)] (5,7)
(1,0) [(6,3) (7,6) (5,7)]
[(1,0) (7,6)]
[7,6]
Is this a promising approach? What is the best way to complement it efficiently?
Is there a better, more efficient approach that is easier to implement?
|
|
|
|
|
Is it a homework?
What is your variant of the solution? What does not work in your solution?
|
|
|
|
|
I need C++ source code for calculating gauge and absolute pressures at any height in water.
|
|
|
|
|
It's a straight calculation but you can only approximate it the formula is the same no matter what computer language you use.
absolute pressure = gravity at surface * density of water * depth you are in the water (height of column of water above aka the weight you are holding up really)
The second term varies by all the things that can make water density vary such as water temperature, salinity etc.
So as any scuba diver knows the calibrations for fresh water is very different to the calibrations for ocean diving and dive computers exist for a reason.
However if you are after the layman answer it's absolute pressure = 1atm * 1 * depth ... so its pretty uniform 9.8m adds 1g (1 atm) pressure to you and it's not hard to write that in C++ for anyone who can write a line of code
pressure = 1 atm * depth
In vino veritas
modified 2-Apr-17 10:39am.
|
|
|
|
|
Member 13100668 wrote: any height
Don't get started on that, unless that's specifically the goal of this assignment. For example, with 100km of water you're already around 1GPa at the bottom, probably turning the water at the bottom into exotic ice (it depends on the temperature of course) with a density of about 1.3 times the normal density of water (so density varies significantly across the column, even more significantly than if you have layers with different temperatures/salinities which is already relevant enough that you have to care about if you're doing Serious Business). Also going that high in altitude makes g drop significantly for the higher layers of water.
|
|
|
|
|
There are mathematical formulas for these which can be simply implemented as C code.
The gauge pressure formula should be provided by the manufacturer of the gauge because it contains gauge specific constants.
Calculating pressure from depth is rather seldom in the oceanographic area. Depth sensors are measuring pressure and the pressure value itself is recorded in dbar (because 1 dbar corresponds to about 1 metre). To get the absolute pressure these sensors usually measure the offset (air pressure) before deployed and subtract this offset from all under water measurements. The advantage of this method is that this eliminates also offset drift errors.
See the Unesco technical papers in marine Science 44: Algorithms for computation of fundamental properties of seawater (PDF)[^] for formulas.
Some of them might be required for the gauge pressure calculation.
It contains also a formula for calculating depth from pressure in seawater which is shown on his own also at Code10[^].
|
|
|
|
|
roh = mgh obviously.
Now you need to know the thickness of the air at any point on the planets surface and adjust for air pressure.
|
|
|
|
|
I am developing a native C++ DLL and unit tests for this DLL. When I try to launch a test, I always get the above mentioned message.
At first glance it seems that a DLL or some DLLs can not be found. However, the unit test DLL is created in the same folder as the DLL to be tested. The working directory is exactly the same as the directory the DLLs reside in. Therefore, this reason can be ruled out.
The IDE is Microsoft Visual Studio 2013 update 4 and the operating system is Windows 10.
How can I get my unit test running? I hope I do not need to bother with command line tools or build scripts.
|
|
|
|
|
Did you see this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
That link is broken. You should quote what 'this' is...
|
|
|
|
|
59 pages into this thread, and 18 months later? Thanks but I'll pass. The link was relevant at the time the OP needed it.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Misread the date but I meant you should (as in its practical to) quote what you're looking at in a link in case the link goes away (as it surely will) people still get context after Microsoft or who ever removes there site down the line.
|
|
|
|
|
Hello everyone!
How could I save the value of a member variable (int m_nCon) in the same text file where I have already save the content of a list control(declared as m_List)?? For the list control I used WriteString(). For the integer member variable I want to save, I used
file.Write(&m_nCon, sizeof(int)); but I got only a big blank space :/ Here is the code:
void CDataDialog::OnBnClickedOk()
{
CStdioFile file(L"sample.txt", CFile::modeCreate |
CFile::modeWrite);
int nCount = m_List.GetItemCount();
for (int x = 0; x < nCount; x++)
{
CString strText1 = m_List.GetItemText(x, 1);
file.WriteString(strText1);
file.WriteString(_T("\n"));
CString strText2 = m_List.GetItemText(x, 2);
file.WriteString(strText2);
file.WriteString(_T("\n"));
}
file.Close();
}
|
|
|
|
|
If you used Write() to write the integer and then used something like Notepad to view the file, it will indeed not look like you'd expect. This is a difference between "binary" and "text" files.
Try something like:
CString s;
s.Format(_T("%d\n"), m_nCon);
file.WriteString(s);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
It worked!!I didn't know the difference! Thank you very much for your answer and the explication!!
|
|
|
|
|
To write list control records into text file use structure
you can write and read entire row of list control.
it will be better to seek the file pointer while reading and writing
|
|
|
|
|
Hi i created a Combobox Button in toolbar. It working fine in my machine. But when i testing it on other machines not all but some with win 10 and 7. It case to stop running application.
ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset)
LRESULT CMainFrame::OnToolbarReset(WPARAM wp, LPARAM)
{
UINT uiToolBarId = (UINT)wp;
switch (uiToolBarId)
{
case IDR_MAINFRAME:
case IDR_MAINFRAME_256:
{
CMFCToolBarComboBoxButton comboButton(ID_COMBO, GetCmdMgr()->GetCmdImage(ID_COMBO, FALSE), CBS_DROPDOWNLIST);
comboButton.AddItem(_T("opt 1"));
comboButton.AddItem(_T("opt 2"));
comboButton.AddItem(_T("opt 3"));
comboButton.SelectItem(0);
m_wndToolBar.ReplaceButton(ID_COMBO, comboButton);
}
break;
}
return 0;
}
Im out of ideas How to make it working.
modified 24-Mar-17 9:49am.
|
|
|
|
|
vojtee wrote: How to make it working. The first thing you need to do is to find out why it is "not working", and explain exactly what "not working" means. Without that information it is impossible to help.
|
|
|
|
|
I cant describe it better than not working .
So i have 2 application. In first app that code is included and in second app that code is not included. First application don't work on some machines but on thers works fine.
Windows do not generate any error. It just start and close immediately.
Second app working fine everywhere.
|
|
|
|
|
Well I am sorry but it is impossible to guess what your code is doing. You have the source code so you need to add some debugging to your program to find out where it is going wrong.
|
|
|
|