+ 1

Exit() exits us from loop or exits us from program????

23rd Jun 2020, 3:57 AM
saurabh
saurabh - avatar
2 Respuestas
0
Try yourself in playground: (1) for (int i=0; i<2; i++); printf("hello\n"); Is "hello" printed ? Yes! (2) for (int i=0; i<2; i++) exit(0); printf("hello\n"); Is "hello" printed ? No! This means that exit() not only exits from the loop, like "break", but also from the program
23rd Jun 2020, 4:13 AM
Bilbo Baggins
Bilbo Baggins - avatar
0
$|<|>_&£ understand two keyword first exit and break Exit terminate the program while break is as a name suggest break the loop if u want exit a program in such conditions File *fptr=fopen("some.txt","r") If(fptr==NULL) exit(1)//it terminate the program 2.break For (i=0;i<9;i++) { If(i==3) break; Printf("%d",i); } Printf("\n%d",i); Output is 12 3 I hope u understand
23rd Jun 2020, 6:31 AM
Noman
Noman - avatar