2 files 1 project

This is a discussion on 2 files 1 project within the C++ Programming forums, part of the General Programming Boards category; If I make 2 files in 1 project, and I execute it, but I want to execute only 1 file ...

  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
    Posts
    23,031
    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,189
    Code:
    void main(void){  // ;)
       submain();
       }
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  4. #4
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    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, 05:43 PM
  2. Working with muliple source files
    By Swarvy in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2008, 09:36 AM
  3. Program Deployment and DLL/OCX Files?
    By dfghjk in forum C++ Programming
    Replies: 5
    Last Post: 06-16-2008, 03:47 AM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 09: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

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