Click here to Skip to main content
15,894,720 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: directx 9 ? Pin
David Crow7-Sep-17 5:12
David Crow7-Sep-17 5:12 
AnswerRe: directx 9 ? Pin
leon de boer7-Sep-17 6:57
leon de boer7-Sep-17 6:57 
QuestionOnce Again Assert in Release and I am lost Pin
ForNow4-Sep-17 13:39
ForNow4-Sep-17 13:39 
QuestionRe: Once Again Assert in Release and I am lost Pin
David Crow4-Sep-17 15:45
David Crow4-Sep-17 15:45 
AnswerRe: Once Again Assert in Release and I am lost Pin
ForNow4-Sep-17 16:01
ForNow4-Sep-17 16:01 
GeneralRe: Once Again Assert in Release and I am lost Pin
leon de boer6-Sep-17 19:09
leon de boer6-Sep-17 19:09 
AnswerRe: Once Again Assert in Release and I am lost Pin
Jochen Arndt4-Sep-17 21:13
professionalJochen Arndt4-Sep-17 21:13 
GeneralRe: Once Again Assert in Release and I am lost Pin
ForNow5-Sep-17 1:22
ForNow5-Sep-17 1:22 
GeneralRe: Once Again Assert in Release and I am lost Pin
Jochen Arndt5-Sep-17 1:39
professionalJochen Arndt5-Sep-17 1:39 
GeneralRe: Once Again Assert in Release and I am lost Pin
ForNow5-Sep-17 1:43
ForNow5-Sep-17 1:43 
GeneralRe: Once Again Assert in Release and I am lost Pin
ForNow7-Sep-17 6:00
ForNow7-Sep-17 6:00 
GeneralRe: Once Again Assert in Release and I am lost Pin
leon de boer7-Sep-17 6:39
leon de boer7-Sep-17 6:39 
GeneralRe: Once Again Assert in Release and I am lost Pin
ForNow8-Sep-17 10:09
ForNow8-Sep-17 10:09 
GeneralRe: Once Again Assert in Release and I am lost Pin
Rick York8-Sep-17 12:54
mveRick York8-Sep-17 12:54 
GeneralRe: Once Again Assert in Release and I am lost Pin
leon de boer8-Sep-17 18:07
leon de boer8-Sep-17 18:07 
GeneralRe: Once Again Assert in Release and I am lost Pin
ForNow9-Sep-17 15:03
ForNow9-Sep-17 15:03 
GeneralRe: Once Again Assert in Release and I am lost I finally figured out the bug .. My reflections Pin
ForNow10-Sep-17 12:50
ForNow10-Sep-17 12:50 
GeneralDeclaration Confuse Pin
Mr. Anup Roy31-Aug-17 6:38
professionalMr. Anup Roy31-Aug-17 6:38 
GeneralRe: Declaration Confuse Pin
leon de boer31-Aug-17 8:37
leon de boer31-Aug-17 8:37 
Well two problems if we imagine it uninitialized that is it will have some random value. The start value could be any integer value.

1.) Your sum starts at some random value then you do this line
sum=sum+workhours;

So your answer is some random value + the work hours.
Why bother calculating anything the total is just some random number.

2.) You print the answer even if you had zero employees you would print some random value.
The compiler will actually throw a warning about this line using uninitialized value due to that

The take home message here is variables don't magically start at zero if you want them to start as zero you need to set it to zero.

There is one subtlety here that when you are in debug mode it will initialize all variables to zero. That doesn't happen in release mode.
So new users when debugging often get caught out because when they look in debug mode sum will start as zero.

So the key here is don't set it to zero, compile in release mode ignoring the warning and run your code and watch some random number display. You will have your answer.
In vino veritas


modified 31-Aug-17 14:46pm.

GeneralSum Multiple Value At a Time Pin
Mr. Anup Roy30-Aug-17 6:18
professionalMr. Anup Roy30-Aug-17 6:18 
GeneralRe: Sum Multiple Value At a Time Pin
jeron130-Aug-17 8:10
jeron130-Aug-17 8:10 
GeneralRe: Sum Multiple Value At a Time Pin
Mr. Anup Roy31-Aug-17 4:25
professionalMr. Anup Roy31-Aug-17 4:25 
GeneralRe: Sum Multiple Value At a Time Pin
jeron131-Aug-17 5:38
jeron131-Aug-17 5:38 
SuggestionRe: Sum Multiple Value At a Time Pin
David Crow30-Aug-17 10:31
David Crow30-Aug-17 10:31 
GeneralRe: Sum Multiple Value At a Time Pin
Mr. Anup Roy31-Aug-17 4:27
professionalMr. Anup Roy31-Aug-17 4:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.