int main()
{
int a = 5;
char* b = "hgfh";
if a == 5
{
a = 6;
}
switch (b + "fgh")
{
b = "Why is this indention different than in the first if?";
b = "Still wondering";
}
return 0;
}
Here is an example of auto-indented code of the bloodshed Dev-Cpp editor.
As you notice the code in the switch is indented at another level than the code in the if block.
I wonder:
How does the indention style work?
Is there a good reason for this indention style?
If not, than is there a way to make every indention level the same? (I know how to get the option screen, but what should I uncheck for regular indention?
Indention has NO effect on the program's functionality. For instance, I could do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int main()
{
int a = 5;
char* b = "hgfh";
if a == 5
{
a = 6;
}
switch (b + "fgh")
{
b = "Why is this indention different than in the first if?";
b = "Still wondering";
}
return 0;
}
And there would be no difference in compilation.
I just ignore it, but the indentation should be based on the level of the loop/conditional statement, while still having no effect on the compilation..
It can be good for organization.
As for how to stop it, JUST IGNORE IT. I do, and no problemo.
@QWERTY: "but the indentation should be based on the level of the loop/conditional statement."
That depends on the code-style you are using. Some styles will not indent, some will indent at different levels. C++ is a language that does not rely on indentation as part of the compilation (like Python) so we can lay our code out anyway we like. This is why contests like the Obfuscated C++ contest exist =\
QWERTYman - Instead of slang that no one else understands why not use standard acronyms and save everyone time!
OP = Original Poster
In Dev-Cpp try Tools > Editor Options then Check "Auto Indent" and Uncheck "Smart Tabs". Smart Tabs will tab to the next non-white character on the line above and can give the results the OP has.