Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 4th, 2007, 08:43 PM
Registered User
 
Join Date: Oct 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default NEED HELP!!!!!!!

I'm trying to write a program for my c++ class that takes binary numbers and converts them to decimal. I have programmed this all fine and dandy, but I'm having trouble with my EOF statement. The program requires that I use 3 functions, the first being to prompt user for 8 digit max binary number, the second converts it to decimal, and the third function displays the results.
    I have everything coded perfectly so far, but the teacher wants me to have the user type '@' when they want to quit the program. Then I should assign @ the value of -1 and send it back to main. When I run my program it freaks out when I type @ because the function is an int function. How do I change it so that I can type '@' without pissing off my computer?
Note: I am not allowed to use arrays, just functions and classes and templates, but I'm not that familiar with classes and templates. PLEASE HELP!!!!!!!!!!!


Reply With Quote
  #2 (permalink)  
Old October 10th, 2007, 11:12 PM
Authorized User
 
Join Date: May 2007
Posts: 28
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Peter_APIIT
Default

1. Declare a char type which used to accept the @.

   if ( char single == '@')
   {
     return 0;
   }
   else
   {
     continue;
   }

I haven't test this approach.

I hope this help.

Linux is the best OS in the world.
Reply With Quote









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.