Thread: may i know what is wrong with this coding? tq

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    5

    may i know what is wrong with this coding? tq

    Code:
    Start(){
    
    
    char exit,key;
    
    
    exit =1;
    
    
     while(exit)
          {
    
    
     key =
    
    
    if ((key & 0x40)==0) exit=0;
    
    
    }
    
    
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    It has syntax errors.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jul 2011
    Location
    Champaign, Illinois, United States
    Posts
    27
    exit can't be a variable name since it is similar to return.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    It's incomplete.

  5. #5
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    Code:
    
    
    Start(){ /* what does it return? compiler should warn */ char exit,key; exit =1; while(exit) { key = /* key equals what now? */ if ((key & 0x40)==0) exit=0; /* don't waste time doing a flag */ } } /* horrible indentation all the way through */


    It should look something like this:

    Code:
    void Start (char key)
    {
        while (!(key & 0x40))
            key;    /* idk. key++? key--? key*=5? you need to specify */
    }

  6. #6
    Registered User
    Join Date
    Jan 2012
    Posts
    69
    That has to be the ugliest code I've ever seen.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 11-14-2011, 06:35 PM
  2. whats wrong with this? no errors but wrong result
    By InvariantLoop in forum C Programming
    Replies: 6
    Last Post: 01-28-2005, 12:48 AM
  3. Replies: 9
    Last Post: 07-15-2004, 03:30 PM
  4. What's wrong with my coding?
    By EeeK in forum C Programming
    Replies: 28
    Last Post: 10-09-2003, 05:32 AM
  5. coding done. Two minor bugs. where did I go wrong?
    By mastering_c in forum C Programming
    Replies: 2
    Last Post: 06-25-2002, 11:21 AM