|
Zac,
I was going back over this code and was confused on a few things. In main() , the call to copy() is made once for the entire file. This, in turn, is supposed to call operator>> once for each line of the file. Is that correct? Using the debugger, I see operator>> getting called only for the first line of the file. I'm not seeing the students vector grow at all. What am I missing?
Thanks,
DC
"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
|
|
|
|
|
Looking back at it, is a slight bug in my example code. Basically, since the id's and grades are both longs, there is no way to tell them apart. It would probably be helpful to modify the output slightly by putting a grade count in between the student id and the first grade so that you can modify the copy call (for obtaining the grades) to just grab that many items (instead of grabbing everything that is left in the file). Another (possibly simpler alternative) would be to grab the student id, and then use getline to obtain the rest of the line, place that string into a stringstream and then call copy on it (this solution has the added benefit of not having to change the input/output file format).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
My bad, Zac. I meant to comment on this thread.
"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
|
|
|
|
|
No problem. I figured as much
It wouldn't take much to get that to be working code, but originally it was just meant as a nudge in the right direction.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
q_p wrote: where the first number of each line will be a student ID number and the next five numbers are grades they got on 5 different tests.
Reminds me of a gradebook program I wrote back in college. There's a lot you can do with this, once you get past the basics.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
When my program blows up, sometimes I get the following error on the next build. To date, the only solution I have found is to close VC++ and restart the computer. This works, but is a bit time consuming. It actually tempts me to get up and wander around while the machine restarts.
LINK : fatal error LNK1104: cannot open file "Debug/tradingdemo.exe"
So, any ideas on how to fix this without restarting?
Thanks
|
|
|
|
|
Oliver123 wrote: So, any ideas on how to fix this without restarting?
Yes
Oliver123 wrote: When my program blows up
Fix the bug that causes the crash. Also you can put exception handling in your code that would notify you of the error without crashing the process.
led mike
|
|
|
|
|
led mike wrote: Also you can put exception handling in your code that would notify you of the error without crashing the process.
I'm a member of the school that thinks this is rarely a good idea. If you're got a crash let it crash; it makes the bug easier to locate and fix. Also it means that JIT debuggers can be used. Also for clients, Dr.Watson will generate a crash dump file (if configured to do so) which can be used for postmortem debugging. In short if a program crashes, the best thing for it to do is crash.
Steve
|
|
|
|
|
Well he is talking about a "developer problem" not a production problem. I use exception handling to debug all the time. I find that a stack trace is extremely helpful in locating bugs.
led mike
|
|
|
|
|
Oliver123 wrote: When my program blows up...
ALWAYS wear eye protection. I prefer goggles and a flight helmet.
If you're running in the debugger (sounds like no) you can Shift-F5 stop debugging.
Otherwise CTRL-ALT-DEL, find tradingdemo.exe in the list of running processes, and end the
process.
|
|
|
|
|
You forgot the final step:
format c:
led mike
|
|
|
|
|
led mike wrote: You forgot the final step
Yeah I guess a quick format isn't too "Time consuming".
edit: format /Q c:
Mark
|
|
|
|
|
I bet that the "tradingdemo.exe" process is still running. Check in task manager. If it is just kill it and you should be able to rebuild.
Steve
|
|
|
|
|
Hi,
I have a Dialog application. In some cases I am displaying data in the main dialog by accessing data in an array:
str2.Format("%02d\t, m_Parse.mChannel[i].m_SV);
str+=str2;
SetDlgItemText(IDC_SAT, str);
etc.
etc.
What I want to do is to have some of the data displayed in different colors other than black. How can I set the color of some data before displaying it?
Can someone help me out?
Jerry
|
|
|
|
|
I think the only control that would allow you to mix colors in the text would be a rich edit
control. You could use read-only rich edit controls.
If that's way overkill for just colored text, you could render the text yourself in response to
the WM_PAINT message using perhaps some/all of these functions:
SelectObject() to select a NULL brush (NULL_BRUSH) into the DC or possibly another font as well
SetTextColor()
SetROP2() to set the foreground mixing mode (to R2_COPYPEN, for example)
SetBkMode() to set the background mixing mode (to TRANSPARENT, for example)
DrawText() to draw the text
Just two possibilities
Mark
|
|
|
|
|
|
|
if your control is Edit see WM_CTLCOLOREDIT
|
|
|
|
|
Ok I will take a look at that...thanks, have a good day.
Jerry
|
|
|
|
|
And see MSDN WM_CTLCOLOR notification.It has an example and also you can see another CTLCOLOR_*
|
|
|
|
|
Hello!
I have been having trouble understanding the function DrawText as defined in the MSDN Library:
int DrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UNIT uFormat);
Can someone provide a simple example as to what this function does? Any help given me to better understand this function is appreciated.
Mike
|
|
|
|
|
The first parameter is a device context. It's a handle to whatever you're drawing on. It could be the screen, a bitmap, printer, etc.
The second parameter is the string you want to draw - no mystery there.
The third parameter tells DrawText how much of the string it should draw - i.e., the length of the string. You can pass it -1, if you want it to draw the entire string.
The fourth parameter is a bounding rectangle, in which the function will draw the text. The coordinates of the rectangle are in whatever units your device context is set to use. A screen device context would typically use pixels as coordinates.
The last parameter tells DrawText how it should go about drawing the string. The DT_SINGLELINE flag specifies that the text should not be broken into several lines. DT_RIGHT would align the text to the right hand side of the bounding rectangle. DT_END_ELLIPSIS tells DrawText to draw "..." on the right hand side, in case the entire text does not fit in the bounding rectangle. These are just some of the flags that exist. I suggest you look at the MSDN documentation for more information. The flags can also be combined using the or operator. For instance: DT_RIGHT | DT_SINGLELINE would tell DrawText to draw the text on one line, and align it to the right.
--
The Show That Watches Back
|
|
|
|
|
Did you see DrawText on MSDN it has one example of it
|
|
|
|
|
Does anybody know how to prevent child windows from drawing over a certain region of the parent window? My top level window has custom borders, when resizing the child controls are moved/resized. In some instances the child control will paint over the custom borders, I would prefer the children to instead be cropped leaving the borders intact. I know this can be avoided using MINMAXINFO but is there any way to do this using regions and/or WM_PAINT/WM_ERASEBKGND?
|
|
|
|
|
How about using the SetWindowRgn() to set the fdrawable region in the window?
Mark
|
|
|
|