-4

Is there any advantages of defining variable names as __00000001, __00000002, etc.?

Example:

int __00000001, __00000002 = 0;
for (__00000001 = 0; __00000001 < 10; __00000001++) {
    __00000002 = __00000002 + __00000001;
}
...

Update: this is mentioned in one of my programming classes a few years ago, and I remembered that the professor said there is some advantages of using it. However, I cannot recall any more information. Maybe I am wrong.

Eric Stdlib
  • 1,292
  • 1
  • 18
  • 32

2 Answers2

5

Those particular variable names are not available for user programs:

All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use. (C11, section 7.1.3, paragraph 1)

So that's a big disadvantage.

rici
  • 234,347
  • 28
  • 237
  • 341
4

Is obfuscating the crap out of your code worthwhile? No, not unless your goal is literally to do just that: to make your code as hard to read as possible. Trouble is, you've got to read it too.

Sometimes you'll run into code like this when somebody's "decompiled" a program — variable names do not survive the compilation process so this is sort of the best a decompiler can do when reconstructing a C++ program. Of course it cannot really reconstruct a C++ program; it can only re-spell the flattened logic in C++ syntax. Oh well.

Addressing your example specifically, it's worth noting that all identifiers beginning with two underscores are reserved to the implementation (your compiler and standard library), so your program has undefined behaviour.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055