Thread: Need Help on creating a Proj on Dev C++

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    5

    Need Help on creating a Proj on Dev C++

    can anyone tell me how to create a project in dev c++ and make it work?? i have 2 simple files that ive created and put in a project but i just cant get it to work . . any help is appreciated .. thanx
    here's the 2 files :
    file a:
    Code:
    #include <stdio.h>
    int p(void)
    int q(void)
    
    main()
    {
       int k;
       k = p();
       printf("%d", k);
       k = q();
       printf("%d", k);
       return EXIT_SUCCESS;
    }
    
    int count = 0;
    
    int p(void)
    {
       count++;
       return count;
    }
    file b:
    Code:
    int q(void)
    {
       extern int count;
       count += 5;
       return count;
    }

  2. #2
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595
    Moved to the C++ board by Kermi3
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  3. #3
    Registered User fry's Avatar
    Join Date
    Mar 2002
    Posts
    128
    You need to include the second file in your main file:
    Code:
     
    #include <stdio.h>
    #include "file_b.h" // easy way out. See below
    
    int p(void);  // need a colon here
    int q(void)   // this line not needed
    
    int main(){  // add 'int'
        int k;   
        k = p();
       printf("%d", k);
       k = q();
       printf("%d", k);
       return EXIT_SUCCESS;
    }
    
    int count = 0;
    int p(void){
       count++;
       return count;
    }
    The easy way out is to call your second file "fileb.h". That way, you just include it, and everything works fine. The more correct way, i believe is to make it "fileb.cpp" and then link that. The difference is that you need to compile both files, and you will have to put any necessary #include lines into both files, not just one.
    IDE: Dev C++ 5
    Lib: Allegro
    OS: Windows 2000

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. export vc++ proj to dev c++
    By jay_uccs in forum C++ Programming
    Replies: 1
    Last Post: 06-26-2005, 07:43 AM
  3. New to Dev C++/<windows.h>...
    By Cilius in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2005, 01:05 AM
  4. Glut and Dev C++, Programs not Quitting?
    By Zeusbwr in forum Game Programming
    Replies: 13
    Last Post: 11-29-2004, 08:43 PM
  5. DEV C++ Limitations?
    By Kirdra in forum Game Programming
    Replies: 3
    Last Post: 09-09-2002, 09:40 PM