My WIN32 (C++) code has a UINT lets call it number. The value of this UINT (or INT doesn't matter) start with a 0 and is recognized as an octal value. It's possible to use the standart operators and the value will keep the octal-system. The same is possible with hex (with foregoing 0x). The problem is I have to use the Value of number in a buffer to calculate with it without changing the value of number. I can assign a value like 07777 to buffer on declaration line but if use an operation like buffer = number the value in buffer is recognized on decimal base.
Anybody has a solution for me?
There's no such thing in C as an "octal value". Integers are stored in binary.
For example, these three constants:
10
012
0xA
all have exactly the same type and value. They're just different notations -- and the difference exists only in your source code, not at run time. Assigning an octal constant to a variable doesn't make the variable octal.
For example, this:
stores the value ten in
n
. You can print that value in any of several formats:In all three cases, the stored value is converted to a human-readable sequence of characters, in decimal, octal, or hexadecimal.
No, because there is no actual problem.
(Credit goes to juanchopanza for mentioning this in a comment.)