0 votes
in C Plus Plus by
Should variables be stored in local blocks in C Programming?

1 Answer

0 votes
by

The use of local blocks for storing variables is unusual and therefore should be avoided, with only rare exceptions. One of these exceptions would be for debugging purposes, when you might want to declare a local instance of a global variable to test within your function. You also might want to use a local block when you want to make your program more readable in the current context.

Sometimes having the variable declared closer to where it is used makes your program more readable. However, well-written programs usually do not have to resort to declaring variables in this manner, and you should avoid using local blocks.

Related questions

0 votes
asked Jan 6 in C Plus Plus by GeorgeBell
0 votes
asked Mar 10, 2020 in C Plus Plus by rahuljain1
...