Thread: 2 files 1 project

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

    2 files 1 project

    If I make 2 files in 1 project, and I execute it, but I want to execute only 1 file how do I do it?
    I made a project with 2 files in it, 1 is int main() and 1 is int submain() now how do I execute the submain file? only int main() executes and I get to errors pls help.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You must have a function called int main.
    If you you only compile and link one file, then both files needs int main.
    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
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Code:
    void main(void){  // ;)
       submain();
       }

  4. #4
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Global variables will be constructed before main() executes, but other than that only the runtime environment can execute something before main().

    Code:
    struct foo 
    {
        foo ( ) { submain(); }
    } runbefore;
    
    int main()
    {
    }
    Most of the time something like this is not appropriate.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating and Empty MFC project in Visual Studio?
    By Swerve in forum Windows Programming
    Replies: 7
    Last Post: 11-01-2008, 04:43 PM
  2. Working with muliple source files
    By Swarvy in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2008, 08:36 AM
  3. Program Deployment and DLL/OCX Files?
    By dfghjk in forum C++ Programming
    Replies: 5
    Last Post: 06-16-2008, 02:47 AM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  5. reinserting htm files into chm help files
    By verb in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2002, 09:35 AM