Click here to Skip to main content
15,904,024 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: i would like to elaborate further Pin
Software_Developer15-Oct-11 1:47
Software_Developer15-Oct-11 1:47 
Both code blocks behave in the same way.

ALWAYS initialize your variables before use:
In the C++ standard, only global variables get default value of zero
if they are not explicitly initialized. For local variables it's not required
for the complier to clean up the content of the memory they are assigned to.
A local variable - if not explicitly initialized - will contain a garbage value.

Code 1
C#
// 0 = FALSE
// 1 = TRUE


bool test=0;
int i=0;

do
{
  //some body
    i++;
    cout<<i<<" ";

}
while(!test);


if test==false then we are stuck in an eternal loop forever.
However if test==true then we only loop once.

The same goes for
Code 2
C#
// 0 = FALSE
// 1 = TRUE

bool test=0;
int i=0;

do
{
//some body
    i++;
cout<<i<<" ";

}
while(test==false);



if test==false then we are stuck in an eternal loop forever.
However if test==true then we only loop once.
GeneralRe: Clarification regarding Boolean variable Pin
Albert Holguin15-Oct-11 7:24
professionalAlbert Holguin15-Oct-11 7:24 
AnswerRe: Clarification regarding Boolean variable Pin
MartyTPS15-Oct-11 16:48
MartyTPS15-Oct-11 16:48 
AnswerRe: Clarification regarding Boolean variable Pin
Pranit Kothari16-Oct-11 20:38
Pranit Kothari16-Oct-11 20:38 
AnswerRe: Clarification regarding Boolean variable Pin
Chuck O'Toole17-Oct-11 5:01
Chuck O'Toole17-Oct-11 5:01 
QuestionProgress Window, where to attach Pin
jkirkerx14-Oct-11 9:42
professionaljkirkerx14-Oct-11 9:42 
QuestionRe: Progress Window, where to attach Pin
David Crow14-Oct-11 10:06
David Crow14-Oct-11 10:06 
AnswerRe: Progress Window, where to attach Pin
jkirkerx14-Oct-11 10:38
professionaljkirkerx14-Oct-11 10:38 
GeneralRe: Progress Window, where to attach Pin
Richard MacCutchan14-Oct-11 23:02
mveRichard MacCutchan14-Oct-11 23:02 
GeneralRe: Progress Window, where to attach Pin
jkirkerx15-Oct-11 7:02
professionaljkirkerx15-Oct-11 7:02 
GeneralRe: Progress Window, where to attach Pin
Richard MacCutchan15-Oct-11 7:09
mveRichard MacCutchan15-Oct-11 7:09 
GeneralRe: Progress Window, where to attach Pin
jkirkerx15-Oct-11 8:13
professionaljkirkerx15-Oct-11 8:13 
GeneralRe: Progress Window, where to attach Pin
Richard MacCutchan15-Oct-11 21:24
mveRichard MacCutchan15-Oct-11 21:24 
GeneralRe: Progress Window, where to attach Pin
jkirkerx16-Oct-11 6:53
professionaljkirkerx16-Oct-11 6:53 
GeneralRe: Progress Window, where to attach Pin
Richard MacCutchan16-Oct-11 7:16
mveRichard MacCutchan16-Oct-11 7:16 
QuestionGetting IP Address from IP Control Pin
pandit8414-Oct-11 2:42
pandit8414-Oct-11 2:42 
AnswerRe: Getting IP Address from IP Control Pin
«_Superman_»14-Oct-11 3:12
professional«_Superman_»14-Oct-11 3:12 
GeneralRe: Getting IP Address from IP Control Pin
pandit8414-Oct-11 3:15
pandit8414-Oct-11 3:15 
AnswerRe: htonl() converts Pin
Software_Developer14-Oct-11 4:48
Software_Developer14-Oct-11 4:48 
QuestionSuggest a third party library for MFC applications Pin
rahul.kulshreshtha13-Oct-11 22:39
rahul.kulshreshtha13-Oct-11 22:39 
AnswerRe: Suggest a third party library for MFC applications Pin
_AnsHUMAN_ 13-Oct-11 23:45
_AnsHUMAN_ 13-Oct-11 23:45 
GeneralRe: Suggest a third party library for MFC applications Pin
App_14-Oct-11 0:42
App_14-Oct-11 0:42 
GeneralRe: Suggest a third party library for MFC applications Pin
rahul.kulshreshtha14-Oct-11 7:17
rahul.kulshreshtha14-Oct-11 7:17 
GeneralRe: Suggest a third party library for MFC applications Pin
rahul.kulshreshtha14-Oct-11 7:14
rahul.kulshreshtha14-Oct-11 7:14 
GeneralRe: Suggest a third party library for MFC applications Pin
_AnsHUMAN_ 16-Oct-11 18:51
_AnsHUMAN_ 16-Oct-11 18:51 

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.