I have to say it was a bit of a trial reading your code, not just 'cause of the formatting! Before slagging people off for their attitude in helping you remember it pays to give them the respect they deserve by posting code that actually compiles - as you couldn't be bothered to stick you code in
tags we can't see your include files for example. Also some idea of what the program does is helpful when it's not obvious from the code (and inthiscase it aint obvious - are you trying to count the lines that start with A or a or just echo a file to the console?)
Look into these things:
- Don't use low level constructs (pointer, arrays, dynamic memory allocation) where a couple of local objects would have done (i.e. use <code>std::vector<std::string> lines( number_of_lines );</code> )
- use variable names that describe what you're doing - i.e. rename adder and A
- Learn how IOStreams work - <code>cin >> fileName;</code> won't work if you have spaces in the filename
- Grab a textbook and have a look at the difference between initialisation and assignment. For example there's no reason to not create your input file object and open it at the same time
- using strlen is completely pointless in a C++ program that's using std::string. Look up the interface to std::string in a decent reference and you'll find a member that does the right thing
Forgive my ignorance and lazyness , i stand corrected.
im used to passing the project down the development cycle
and letting someone better like for instance a senior software engineer do the cleaning up of code.
I'd like to step through the Microsoft code for dawing a CTabCtrl. In winctrl2.cpp, CTabCtrl::DrawItem consists only of ASSERT (FALSE); When I put a breakpoint here, it is not hit. If I put a break at CWnd::OnDrawItem it is hit, but stepping through doesn't land in the drawing code, and I don't know where to put a break to see the code that does the computations for the drawing.
Can you tell me how to set a breakpoint so I can step through this code? Thanks.
I am trying to add a combo box to provide a list of choice to the user. I add it to a dialogue box and entered Listbox items, but when I try to run to see the list, it is not there. I guess I need more work to make it work for me.
In the simple application I have two dialogue box. One is for input and the other for display results.
I use Edit box to display results of calculated numbers (float or int). Then each edit box have a tittle
above it by Static Text.
Ideally I can change the static text according to the input since this static text should show the unit of the
displayed numbers. The unit depends on the input selection of the units.
How to change the static text on fly by the application according to the input selection from the input combo box.
m_pv_unit is declared in the header file of Class A: CString m_pv_unit; which is assigned value from Combo Box.
Class B is the for the output display. Class B includes the header file of Class A. However, I tried to use the variable: m_pv_unit to change the static text (the tittle of the output edit box), I got error message from the compile:
'm_pv_unit' : undeclared identifier
How to make: m_pv_unit to be see in Class B ? Or how to pass the variable: m_pv_unit and its value in Class A to methods in Class B. Class B (its methods) is called by Class A.
The method of Class B displays the results processed by Class A.
Have had an app running for years and now suddenly it is unable to delete files. It is processing the data in the files. The only step it seems unable to complete now is the file deletion.
I have checked the directory permissions and even recreated the directory. Has there been any recent Windows update that would make a call to CFile::Remove fail? Any other ideas what might be going on?
No exception is being thrown. The program reads the contents of the file into memory, deletes the file, and then processes the data. If an exception were being thrown the data would not be processed. I can clearly see in the database though that it is.
The program has been running correctly about five years now. I am hoping somebody has an idea what I can check without having to modify the code.
Perhaps you should read my posts. The data in the file is read into memory before I attempt to delete the file. I am trying to get help diagnosing why a long running program would fail without modifying the code.
Since the read/delete/process occur in that order within the try/catch and the data is being processed, I know that CFile::Remove is not throwing an exception. Is there an error condition of DeleteFile() for which CFile::Remove would not throw an exception?
Since CFile::Remove() is just a thin wrapper around DeleteFile(), why not call DeleteFile() directly? If it fails, call GetLastError() to find out why? This is what Remove() is doing when it throws an exception.
"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
"Man who follows car will be exhausted." - Confucius
Last Visit: 31-Dec-99 18:00 Last Update: 1-Oct-23 19:46