problem with switches and loops

This is a discussion on problem with switches and loops within the C Programming forums, part of the General Programming Boards category; i cant figure out why this prog crashes it doesnt exit or anything, but it just keeps repeating the information ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    2

    Question problem with switches and loops

    i cant figure out why this prog crashes
    it doesnt exit or anything, but it just keeps repeating the information its supposed to say
    Attached Files Attached Files
    • File Type: c char.c (450 Bytes, 80 views)

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    2

    Post

    Please Note:
    the program is being run under Windows at a DOS command prompt

  3. #3
    Unregistered
    Guest

    Red face

    In C, your program can not be allowed to make
    recursive call with main() function.
    Only OS is allowed to call your program's main()
    function. So remove the call main() in default
    of switch statement.
    Good luck
    DV007

  4. #4
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    1. It's not compiling on my system (need to include process.h).
    2. Use int main(void) and return something!
    3. Don't call main in main. This is wrong!
    4. Don't use while(1), use while(c != 'x' && c != 'X')

  5. #5
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Originally posted by Monster
    use while(c != 'x' && c != 'X')
    This must be: while((char)c != 'x' && (char)c != 'X')

    Cheers, Monster

Popular pages Recent additions subscribe to a feed

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