break or return

This is a discussion on break or return within the Windows Programming forums, part of the Platform Specific Boards category; It might be a dumb question but its confusing me at times, when to use "break" and when to use ...

  1. #1
    Registered User SAMSAM's Avatar
    Join Date
    Nov 2001
    Posts
    218

    break or return

    It might be a dumb question but its confusing me at times,

    when to use "break" and when to use "return 0", in responce to some window messages like WM_VSCROLL .ie

    ,,,,,,,,,,,,,,,,
    case SB_TOP:
    process,,,,,
    break;

    or in regard to some other messages at times choosing either one makes no difference at all,.i know that by sending return 0 you are telling the win that u have orocessed the message but doesnt break statement do the same thing?
    Last edited by SAMSAM; 01-30-2003 at 04:34 PM.

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    as a rule, I try to make my functions have ONE exit point. this should be at the end of the function. therefore you would always use break in your case statement.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    157
    i always return right away. if you break and you know that it will definitely return, then it will just be easier to follow/debug. to see a break and tehn follow the break is just rediculous if you just return after the break.

    make things as clear as possible!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New string functions
    By Elysia in forum C Programming
    Replies: 11
    Last Post: 03-28-2009, 05:03 AM
  2. Number to Word (Billions)
    By myphilosofi in forum C Programming
    Replies: 34
    Last Post: 02-04-2009, 01:09 AM
  3. Another weird error
    By rwmarsh in forum Game Programming
    Replies: 4
    Last Post: 09-24-2006, 10:00 PM
  4. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 06:48 PM
  5. Extra printed stmts...why?
    By mangoz in forum C Programming
    Replies: 4
    Last Post: 12-19-2001, 06:56 AM

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