moving functions into visual compilers

This is a discussion on moving functions into visual compilers within the C++ Programming forums, part of the General Programming Boards category; Bit of a problem here that I've sort of run into blindly not really thinking ahead of myself. I wrote ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    99

    moving functions into visual compilers

    Bit of a problem here that I've sort of run into blindly not really thinking ahead of myself. I wrote a program, command line which basically has a few functions in it. It works fine and I was happy with it. I then decided to throw it into borland builder to make a little GUI for it only this is where im having problems. When i place the code under a button component it is a totaly different kettle of fish to me. I cnt use the 'int main' inside the button bracket (probs sounds obvious but i didnt think until i actually came to doing it) and it doesnt recognize any of my calls to the functions!? I'm a bit stumped

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,537
    Basically, you need to realize that "under" your button, is a function. So put the code INSIDE the function, do not create another one.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    99
    I have been doing a bit of messing around to see what I can get from it. I understand what your saying I think i just have to work away of making my code fit in, if that makes sense. my basic shape of code looks like below. I'm guessing that its not just a case of stripping away all the function tags and main tags and it works? Sorry for my VERY basic minded approach but it is confusing me abit!

    Code:
    
    button                                   //would be the tags for the button
    {
    
    
    
    
    function 1()
    {
    
    }
    
    
    function 2()
    
    {
    
    
    }
    
    
    int main()
    {
    
    
    }
    
    
    
    } // end of button

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,537
    No, you can't have functions inside functions.
    Put the code you want the button to do inside the button.
    Put the rest of the functions OUTSIDE the button function.

    For example, if the button code is inside main, move the entire code in main inside the button { }.
    Then put the rest of the functions after the ending } for the button.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    99
    Brilliant!!!!!!!!!!!!!

    thank you very much for the help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Templates and Macros plus more...
    By Monkeymagic in forum C++ Programming
    Replies: 8
    Last Post: 01-20-2007, 04:53 PM
  2. Functions in C
    By shoobsie in forum C Programming
    Replies: 15
    Last Post: 11-17-2005, 12:47 PM
  3. Erros in Utility Header File
    By silk.odyssey in forum C++ Programming
    Replies: 4
    Last Post: 12-22-2003, 05:17 AM
  4. Moving from Visual Basic to Visual C++
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 04-10-2002, 09:57 PM
  5. <conio.h> in Borland (or VIsual) C++ compilers?
    By William in forum C Programming
    Replies: 1
    Last Post: 04-07-2002, 03:27 PM

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