homework problem Please Help!

This is a discussion on homework problem Please Help! within the C Programming forums, part of the General Programming Boards category; Originally Posted by Dave_Sinkula Okay, hasty reply. Declare or define ? [Sorry, lacking K&R2.] Declare...

  1. #16
    Registered User
    Join Date
    Jun 2006
    Posts
    75
    Quote Originally Posted by Dave_Sinkula
    Okay, hasty reply. Declare or define? [Sorry, lacking K&R2.]
    Declare

  2. #17
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Okay, there you go.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #18
    Registered User
    Join Date
    Aug 2005
    Posts
    11
    Quote Originally Posted by noodles
    Why not?
    it is not the standard. define or declare it does not matter.

  4. #19
    Registered User
    Join Date
    Jun 2006
    Posts
    75
    Quote Originally Posted by Three
    it is not the standard. define or declare it does not matter.
    C&V, please

  5. #20
    Registered User
    Join Date
    Aug 2005
    Posts
    11
    What is C&V ?

  6. #21
    Registered User
    Join Date
    Jun 2006
    Posts
    75
    Chapter and Verse, please

  7. #22
    Registered User
    Join Date
    Aug 2005
    Posts
    11
    This is obviously pointless.

  8. #23
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,738
    Christ on a cross. There is nothing in the Standard that prohibits you from putting a function prototype in a function. It's just an incredibly stupid idea. To give a rather discrete example:
    Code:
    void bar()
    {
       /* I guess bar does other stuff too. */
       foo();
    }
    
    void foo(void) 
    {
    }
    
    int main(void)
    {
       void foo(void);
       foo();
       bar();
       return 0;
    }
    You'll get a compiler error for conflicting types of foos. With this foo() can't be used outside of main().
    Last edited by whiteflags; 10-27-2006 at 01:21 AM.

  9. #24
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Your example is flawed. The reason you can't use foo in bar is because you're trying to call it before it's been seen anywhere. You can never do that. That has nothing really to do with prototyping inside of a function or not.


    Quzah.
    Hope is the first step on the road to disappointment.

  10. #25
    Registered User
    Join Date
    Jun 2006
    Posts
    75
    Quote Originally Posted by citizen
    There is nothing in the Standard that prohibits you from putting a function prototype in a function. It's just an incredibly stupid idea.
    I suggest you look up the page nos I mentioned from K&R2, they've provided some good examples of it's usage (i.e making functions available only to functions that need them, like the idea of using local variables instead of global ones).

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. One More Homework Problem
    By joxerjen in forum C++ Programming
    Replies: 5
    Last Post: 10-12-2005, 04:39 PM
  2. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  3. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  4. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM
  5. homework assignment problem
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 10-29-2001, 09:24 AM

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