Bloodshed Dev-Cpp indention.

Jun 18, 2008 at 4:49pm
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;
}


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?
Jun 18, 2008 at 6:40pm
This is just another variation on the many indentation styles. You can pick one that you are most familiar with.

Personally, I prefer the K&R style with Tabs set to spaces and my indentation set to 2.
Jun 18, 2008 at 6:42pm
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.
Last edited on Jun 18, 2008 at 6:50pm
Jun 18, 2008 at 6:44pm
@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 =\
Jun 18, 2008 at 6:49pm
Whoops, sry.
New at this (fairly). Just going off of what I know from Dev-Cpp, which happens to be what the TC is using, so...
Jun 18, 2008 at 6:51pm
TC?
Jun 18, 2008 at 6:51pm
Topic creator. I use slang. Sorry.
Last edited on Jun 18, 2008 at 6:51pm
Jun 19, 2008 at 4:31am
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.

Alan
Last edited on Jun 21, 2008 at 2:06am
Topic archived. No new replies allowed.