Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: octal error
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 12 of 26 Topic 45831 of 48022
Post > Topic >>

Re: octal error

by =?UTF-8?B?RXJpayBXaWtzdHLDtm0=?= <Erik-wikstrom@[EMAIL PROTECTED] > May 10, 2008 at 02:39 PM

On 2008-05-09 23:59, Victor Bazarov wrote:
> notahipee wrote:
>> This is all of it.
>> #include <iostream>
>> #include <ostream>
>> 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;
>> case 08: cout << zero eight;
>> case 09: cout << zero ninne;
>> }
>>
>> return 0;
>> }
> 
> And what errors you get?  I believe you just need to drop the
> leading zero in all of your 'case' labels, but that's just
> a guess.
> 
> What is it you're trying to accomplish with the leading 0?
> Keep in mind that whatever form you enter your 'a' in, is
> getting converted into the internal representation which is
> just a value.  And if you want to put octal numbers in your
> 'case' labels, you shouldn't use '08' or '09' since they are
> not octal numbers, use '010' and '011'...

Even assuming that you drop the leading zeros (and fix the other issues)
the program will not work as expected since it will print "zero one"
even if the user just entered "1".

If you explain what you are trying to do (not getting the switch
statement to work, but rather why you have it to begin with) we might be
able to help you more.

-- 
Erik Wikström
 




 26 Posts in Topic:
octal error
notahipee <werldpeace@  2008-05-09 14:14:28 
Re: octal error
"Victor Bazarov"  2008-05-09 17:22:52 
Re: octal error
notahipee <werldpeace@  2008-05-09 14:36:12 
Re: octal error
"Victor Bazarov"  2008-05-09 17:53:19 
Re: octal error
"kwikius" <a  2008-05-09 22:54:06 
Re: octal error
"Default User"   2008-05-09 22:01:34 
Re: octal error
"kwikius" <a  2008-05-09 23:10:49 
Re: octal error
Juha Nieminen <nospam@  2008-05-10 09:30:42 
Re: octal error
"Default User"   2008-05-09 21:48:37 
Re: octal error
notahipee <werldpeace@  2008-05-09 14:53:58 
Re: octal error
"Victor Bazarov"  2008-05-09 17:59:38 
Re: octal error
=?UTF-8?B?RXJpayBXaWtzdHL  2008-05-10 14:39:05 
Re: octal error
notahipee <werldpeace@  2008-05-09 15:12:46 
Re: octal error
"kwikius" <a  2008-05-09 23:36:35 
Re: octal error
"Default User"   2008-05-09 22:54:42 
Dates (was Re: octal error)
Andy Champ <no.way@[EM  2008-05-10 18:20:31 
Re: octal error
notahipee <werldpeace@  2008-05-09 15:17:34 
Re: octal error
notahipee <werldpeace@  2008-05-09 15:18:46 
Re: octal error
notahipee <werldpeace@  2008-05-09 16:18:08 
Re: octal error
James Kanze <james.kan  2008-05-10 08:14:54 
Re: Dates (was Re: octal error)
James Kanze <james.kan  2008-05-11 08:37:57 
Re: Dates (was Re: octal error)
Andy Champ <no.way@[EM  2008-05-11 21:26:28 
Re: Dates (was Re: octal error)
James Kanze <james.kan  2008-05-11 16:41:24 
Re: Dates (was Re: octal error)
Andy Champ <no.way@[EM  2008-05-12 23:08:03 
Re: octal error
Nick Keighley <nick_ke  2008-05-12 06:47:48 
Re: Dates (was Re: octal error)
James Kanze <james.kan  2008-05-13 02:06:58 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 11:21:10 CDT 2008.