c - Why does this print 1? -


#include <stdio.h>   int main()  {    int var=0;    for(; var++; printf("%d",var));      printf("%d", var);  }  

please explain me c code. how output 1?

you might confused because of wrong code indentation. code is:

for(; var++; printf("%d",var))     ;  printf("%d", var);  

so output of second printf. var initialized 0 , var++ (the for-condition) executed, end var==1.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -