Hello,
I'm trying to make a code that acts as a simple menu for a number of programs. What I was wondering was how do I include the .ccp files and run them in the menu program. Here's what I have so far:

#include <stdio.h>
#include <stdlib.h>
#include "1.cpp"
#include "2.cpp"
#include "3.cpp"
#include "4.cpp"

int main()
{
    int select;
    
    printf("Assignments\n");
    printf("-----------\n\n");
    printf("1. Multiple of 5\n2. Calculator\n3. Rock, Paper, Scissors\n4. No Vowels (incomplete)\n7. Exit\n");
    scanf(" %d", &select);
    
    switch(select)
    {
                  case 1:
                          a1();
                          break;
                          
                  case 2: 
                          a2();
                          break;
                          
                  case 3:
                         a3();
                         break;
                         
                  case 4:
                         a4();
                         break;
                          
                  default:
                          printf("That's not a choice.\n");
                          break;
    }
    
    system("PAUSE");
    return 0;
}

I've placed all the files in the same folder and also created a project. I also tried putting the full file name for each file but I kept getting the same error: multiple definition of `a1()' or a2(), etc...

Any help will be greatly appreciated.

In general, never #include source files. Learn about separate compilation and linking.

Thanks for your help guys. I figured it out using this link: http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044654269&id=1043284392. Here's the code that I ended up with:

#include <stdio.h>
#include <stdlib.h>
#include <process.h>

int main(void)
{
    int select;
    
    printf("Assignments\n");
    printf("-----------\n\n");
    printf("1. Multiple of 5\n2. Calculator\n3. Rock, Paper, Scissors\n4. No Vowels (incomplete)\n7. Exit\n");
    scanf(" %d", &select);
    
    switch(select)
    {
                  case 1:
                          spawnl( P_OVERLAY, "1.exe",
                          "1.exe", "1.exe", "Arg1", "Arg2", NULL );
                          break;
                          
                  case 2: 
                          spawnl( P_OVERLAY, "2.exe",
                          "2.exe", "2.exe", "Arg1", "Arg2", NULL );
                          break;
                          
                  case 3:
                         spawnl( P_OVERLAY, "3.exe",
                         "3.exe", "3.exe", "Arg1", "Arg2", NULL );
                         break;
                         
                  case 4:
                         spawnl( P_OVERLAY, "4.exe",
                         "4.exe", "4.exe", "Arg1", "Arg2", NULL );
                         break;
                         
                  case 7:
                         break;
                          
                  default:
                          printf("That's not a choice.\n");
                          break;
    }
    
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.