Thread: What a function entry point?

  1. #1
    KoolGuy18
    Guest

    What a function entry point?

    Hello people,

    I just kick off learning programming language. The book each
    routine in a program has only one ENTRY point and one EXIT point. I am not quite understanding what this mean. Does it mean that a function is allowed to accept only one parameter and
    return only one value?

    Ca'm on ra^'t nhieu ve^` gia?i thi'ch cu?a ca'c ba.n and your help.
    Muncho Gracias!

    KoolGuy18

  2. #2
    Evil Member
    Join Date
    Jan 2002
    Posts
    638

    Not quite...

    Thats a principle of well written code, that functions only start at the top and only end at the bottom.

    The idea is that:

    Code:
    int myfunc (int arg, double another) {
    
       //Do stuff
    
       int something;
    
       switch (some_variable) {
    
          case 1:
    
             something = 6;
    
          break;
    
          case 2:
    
             something = 9;
    
          break;
    
       }
    
       return something;
    
    }
    Is good, whilst

    Code:
    int myfunc (int arg, double another) {
    
       //Do stuff
    
       switch (some_variable) {
    
          case 1:
    
             return 6;
    
          break;
    
          case 2:
    
             return 9;
    
          break;
    
       }
    
    }
    Is not, because it exits in several places. As that switch statement gets more and more complex, it can be harder to think it though and find out what is happening in various situations. This can lead to spaghetti code.

    As for entrances, it is very unusual that any modern code would use function with more than one entry point, but it would be a Bad Thing to try and do.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. Entry Point Not Found?!
    By pobri19 in forum C++ Programming
    Replies: 2
    Last Post: 10-25-2008, 09:00 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM