octal error
  Home FAQ Contact Sign in
comp.lang.c++ only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.c++ Profile…
 Up
octal error         


Author: notahipee
Date: May 9, 2008 14:14

I have been trying to cin an number from 0 to 9 with a leading 0. For
example 00 or 07. I was using a switch case.
switch (int)
{
case 01: break;
case 02: break;.....
My problem arises at 08 and 09 because they are not octal. Is there
any way to coerce the input variable to decimal despite it having a
leading zero .
25 Comments
Re: octal error         


Author: Victor Bazarov
Date: May 9, 2008 14:22

notahipee wrote:
> I have been trying to cin an number from 0 to 9 with a leading 0. For
> example 00 or 07. I was using a switch case.

You were using a switch case for what?
> switch (int)
^^^^^^^^^^^
That's a syntactically incorrect statement.
> {
> case 01: break;
> case 02: break;.....
> My problem arises at 08 and 09 because they are not octal.

What problem would that be?
> Is there
> any way to coerce the input variable to decimal despite it having a
> leading zero .

This is a glimmer of an actual problem you seem to be having... But
I am not seeing the alleged behaviour in the following program.
Show full article (0.96Kb)
no comments
Re: octal error         


Author: notahipee
Date: May 9, 2008 14:36

What I was trying to do looks like this:
#include
#include
int main()
{
int a;

cout << "enter a number " << endl;
cin >> a;
switch (a)
{
case 00: cout << zero;
case 01: cout << zero one;
etc.
}
Since a leading zero changes the number to octal it crashes at 08 and
09.
no comments
Re: octal error         


Author: Default User
Date: May 9, 2008 14:48

notahipee wrote:
> I have been trying to cin an number from 0 to 9 with a leading 0. For
> example 00 or 07. I was using a switch case.
> switch (int)
> {
> case 01: break;
> case 02: break;.....
> My problem arises at 08 and 09 because they are not octal. Is there
> any way to coerce the input variable to decimal despite it having a
> leading zero .

Please post complete, minimal code that demonstrates the problem.

Brian
no comments
Re: octal error         


Author: Victor Bazarov
Date: May 9, 2008 14:53

notahipee wrote:
> What I was trying to do looks like this:
> #include
> #include
> int main()
> {
> int a;
>
> cout << "enter a number " << endl;
> cin >> a;
> switch (a)
> {
> case 00: cout << zero;
> case 01: cout << zero one;
> etc.
> }
> Since a leading zero changes the number to octal it crashes at 08 and
> 09.

FAQ 5.8.
Show full article (0.49Kb)
no comments
Re: octal error         


Author: notahipee
Date: May 9, 2008 14:53

This is all of it.
#include
#include
int main()
{
int a;
Show full article (0.45Kb)
no comments
Re: octal error         


Author: kwikius
Date: May 9, 2008 14:54

"notahipee" hotmail.com> wrote in message
news:9a2c7b62-8001-474c-8e56-8ee13f585ebc@s50g2000hsb.googlegroups.com...
> What I was trying to do looks like this:
> #include
> #include
> int main()
> {
> int a;
>
> cout << "enter a number " << endl;
> cin >> a;
> switch (a)
> {
> case 00: cout << zero;
> case 01: cout << zero one;
> etc.
> }
> Since a leading zero changes the number to octal it crashes at 08 and
> 09.
Show full article (0.54Kb)
no comments
Re: octal error         


Author: Victor Bazarov
Date: May 9, 2008 14:59

notahipee wrote:
> This is all of it.
> #include
> #include
> int main()
> {
> int a;
>
> cout << "enter a number " << endl;
> cin >> a;
> switch (a)
> {
> case 00: cout << zero;
> case 01: cout << zero one;
> case 02: cout << zero two;
> case 03: cout << zero three;
> case 04: cout << zero four;
> case 05: cout << zero five;
> case 06: cout << zero six;
> case 07: cout << zero seven; ...
Show full article (1.11Kb)
no comments
Re: octal error         


Author: Default User
Date: May 9, 2008 15:01

notahipee wrote:
> What I was trying to do looks like this:
> #include
> #include
> int main()
> {
> int a;
>
> cout << "enter a number " << endl;
> cin >> a;
> switch (a)
> {
> case 00: cout << zero;
> case 01: cout << zero one;
> etc.
> }
> Since a leading zero changes the number to octal it crashes at 08 and
> 09.

The simple answer is, "don't do that".
Show full article (0.51Kb)
no comments
Re: octal error         


Author: kwikius
Date: May 9, 2008 15:10

"Default User" yahoo.com> wrote in message
news:68jvtuF2t43tsU1@mid.individual.net...
> notahipee wrote:
>
>> What I was trying to do looks like this:
>> #include
>> #include
>> int main()
>> {
>> int a;
>>
>> cout << "enter a number " << endl;
>> cin >> a;
>> switch (a)
>> {
>> case 00: cout << zero;
>> case 01: cout << zero one;
>> etc.
>> }
>> Since a leading zero changes the number to octal it crashes at 08 and ...
Show full article (0.74Kb)
no comments

RELATED THREADS
SubjectArticles qty Group
aggiornamento errore [Numero errore: 0x8007007B]microsoft.public.it.windowsupdate ·
1 2 3