Click here to Skip to main content
15,897,718 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Using MFC dialogs in a dll [VS2005] Pin
KarstenK29-Mar-07 3:11
mveKarstenK29-Mar-07 3:11 
GeneralRe: Using MFC dialogs in a dll [VS2005] Pin
benjymous29-Mar-07 3:25
benjymous29-Mar-07 3:25 
QuestionWhy? Pin
_808628-Mar-07 23:16
_808628-Mar-07 23:16 
AnswerRe: Why? Pin
Rohde28-Mar-07 23:26
Rohde28-Mar-07 23:26 
AnswerRe: Why? Pin
benjymous28-Mar-07 23:28
benjymous28-Mar-07 23:28 
GeneralRe: Why? Pin
_808629-Mar-07 0:51
_808629-Mar-07 0:51 
AnswerRe: Why? Pin
prasad_som28-Mar-07 23:29
prasad_som28-Mar-07 23:29 
AnswerRe: Why? Pin
toxcct28-Mar-07 23:30
toxcct28-Mar-07 23:30 
first of all, when posting code, please use the <pre></pre> tags to keep a well formated message.

then, to understand your result, keep in mind that static variables (declared within a function) stay local to the function (so, not visible from outside) but their lifetime changed to being the program lifetime. that is, a local static variable is initialized at the beginning of the application, and is destroyed when the program exits.
at the first call of the function, the variable as the initialization value. then, each time the function is called, it keeps the last value it had when the function last exited.
int main() {
    static int i=3;
    printf("%d", i--);
    return i>0 ? main():0;
}

1. entering main for the first time:
i == 3
so, 3 is printed (because the i-- decremented the variable only after returning the current value)
i now equals 2
the i>0? main : 0 expression is evaluated. as i is strictly higher than 0, main() calls itself recursively

2. entering main for the second time:
i == 2
printing 2
i == 1 (after decrementation)
i > 0, so re-entering main()

3. entering main for the third time:
i == 1
printing 1
i == 0 (after decrementation)
i not > 0, so returning 0

for all the previous calls to main, the expression returns 0 either, until exiting...


GeneralRe: Why? Pin
Eytukan29-Mar-07 1:34
Eytukan29-Mar-07 1:34 
GeneralRe: Why? Pin
toxcct29-Mar-07 2:13
toxcct29-Mar-07 2:13 
AnswerBecause... Pin
CPallini29-Mar-07 0:16
mveCPallini29-Mar-07 0:16 
Questionconnectivity of c++ with sql only Pin
p_28-Mar-07 22:29
p_28-Mar-07 22:29 
AnswerRe: connectivity of c++ with sql only Pin
prasad_som28-Mar-07 23:25
prasad_som28-Mar-07 23:25 
AnswerRe: connectivity of c++ with sql only Pin
Mark Salsbery29-Mar-07 7:05
Mark Salsbery29-Mar-07 7:05 
Questionget LAN speed using VC++/MFC Pin
sanjaylk28-Mar-07 22:25
sanjaylk28-Mar-07 22:25 
QuestionHow to Customize the IDE of Visual C++ Pin
poda28-Mar-07 22:16
poda28-Mar-07 22:16 
AnswerRe: How to Customize the IDE of Visual C++ Pin
prasad_som28-Mar-07 22:57
prasad_som28-Mar-07 22:57 
QuestionUpgrade VC++ Application to VC++.NET Pin
deepasaral28-Mar-07 22:13
deepasaral28-Mar-07 22:13 
AnswerRe: Upgrade VC++ Application to VC++.NET [modified] Pin
prasad_som28-Mar-07 22:50
prasad_som28-Mar-07 22:50 
GeneralRe: Upgrade VC++ Application to VC++.NET Pin
toxcct28-Mar-07 22:54
toxcct28-Mar-07 22:54 
GeneralRe: Upgrade VC++ Application to VC++.NET Pin
prasad_som28-Mar-07 22:56
prasad_som28-Mar-07 22:56 
QuestionCTreeView control - problem in recognize item that was click. Pin
Yanshof28-Mar-07 21:43
Yanshof28-Mar-07 21:43 
QuestionRe: CTreeView control - problem in recognize item that was click. Pin
prasad_som28-Mar-07 23:13
prasad_som28-Mar-07 23:13 
QuestionListview image problem Pin
amitmistry_petlad 28-Mar-07 21:24
amitmistry_petlad 28-Mar-07 21:24 
AnswerRe: Listview image problem Pin
Naveen29-Mar-07 2:50
Naveen29-Mar-07 2:50 

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.