is there anyway to store a number such as 012345 or 012346 or 012347 as an integer or double, not as a string, without losing the zero at the beginning?
is there anyway to store a number such as 012345 or 012346 or 012347 as an integer or double, not as a string, without losing the zero at the beginning?
No - the zero is simply a means of representing an integer
1
and
000000001
are the same numeric value
printing things with leading zeros is up to you
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Well, think you are unaware of the fact that any literal preceeded by 0 is not taken as a decimal number by C, rather it is taken to be an octal number. So if you put 0 before any numeric literal, you actually mean to say to the c Compiler that it is an octal number and that may generate an error too if you have used some digit more than or equal to 8.
As Salem said, "No"Originally posted by flip114
is there anyway to store a number such as 012345 or 012346 or 012347 as an integer or double, not as a string, without losing the zero at the beginning?
But he didn't mention that the way to output a number with the leading 0's use the format specifier with a leading 0:
printf("Number is %06d \n", val);
will print a 6-character value with leading 0s'
Definition: Politics -- Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers