+ 1
declaring variable inside/outside the loop which is better?
ex #1 while(condition) { int temp; ... } ex #2 int temp; while(condition) { ... } when temp is only used inside the loop, is there any difference between those two? if there is which is better example?
1 Odpowiedź
+ 5
If you declare it inside it becomes local and when loop ends it gets deleted, this can free-up memory but this int won't be accessible from outside…