using own function in writing a function

This is a discussion on using own function in writing a function within the C Programming forums, part of the General Programming Boards category; can I use a function (written by myself) in writing a new function?...

  1. #1
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103

    Question using own function in writing a function

    can I use a function (written by myself) in writing a new function?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,968
    Yes.
    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
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Sure. Is this what you meant:
    Code:
    void func()
    {
        printf("void newfunc()\{\n\tprintf(\"Hello, World\\n\");\n}\n");
    }
    Obviously, you may make this as complicated as you like, and output it to a file if you like.

    [I know, this is probably NOT what you meant to ask for, but I couldn't resist answering a different one... ]

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    May 2008
    Location
    IR, Iran
    Posts
    103
    then, I should define which one first?

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by behzad_shabani View Post
    then, I should define which one first?
    Doesn't really matter - it's a style issue. If you are only calling one from the other, then I personally prefer to put the outermost (called last) first, and then work in towards main. But I starting programming in Pascal many years ago, and in Pascal you are not meant to forward declare function unless one calls the other recursive manners.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

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. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  4. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM
  5. Replies: 3
    Last Post: 03-04-2005, 01:46 PM

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