Like Tree5Likes
  • 5 Post By laserlight

may i know what is wrong with this coding? tq

This is a discussion on may i know what is wrong with this coding? tq within the C Programming forums, part of the General Programming Boards category; Code: Start(){ char exit,key; exit =1; while(exit) { key = if ((key & 0x40)==0) exit=0; } }...

  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
    21,704
    It has syntax errors.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    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, 05:35 PM
  2. whats wrong with this? no errors but wrong result
    By InvariantLoop in forum C Programming
    Replies: 6
    Last Post: 01-27-2005, 11:48 PM
  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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21