
- Forum
- Programming Talk
- C and C++
- What happens when declared this way
What happens when declared this way
This is a discussion on What happens when declared this way within the C and C++ forums, part of the Programming Talk category; Is it possible to declare variable inside the for loop like for (int a = 0; a<5;a++) { ...... ...... ...
-
What happens when declared this way
Is it possible to declare variable inside the for loop like
for (int a = 0; a<5;a++)
{
......
......
}
I want to know whether the above declaration of variables is possible in all types of C compilers.
-
I don't know about all compilers but all the ones that I have worked with did support this functionality.
-
Yes you can very well do that. This is because you are declaring the loop variable inside the loop variable initialization part of for loop which is supported by all types of C compilers.
-
Sponsored Ads

Reply With Quote





