Hello,
I was working with my C++ homework, and I wanted to combine a couple of projects. Now I've never done anything with project-projects before... it's all been one-file console applications in single "*.cpp" files.
Well, I tried my hand at combining two projects into one project file, so I could expand my knowledge, but it didn't seem to work all that well.
in my main.cpp file, I have the following code:
#include <iostream>
#include "Project 10-2.cpp"
#include "Project 10-3.cpp"
#include <cstdlib>
using namespace std;
int main()
{
int choice;
do
{
cout << "Welcome to my project! Please choose an option listed below:\n"
<< "------------------------------------------------------------\n"
<< "1) Encrypt a word\n"
<< "2) Decrypt a word\n"
<< "0) QUIT\n"
<< ">";
cin >> choice;
switch(choice)
{
case 1:
encrypt();
break;
case 2:
decrypt();
break;
case 3:
system("CLS");
cout << "PROCESS TERMINATING."
break;
default:
system("CLS");
cout << "please choose from one of the above options.\n"
break;
}
}
return 0;
}
In Project 10-2.cpp I have:
#include <iostream>
#include <cstdlib>
using std::cout;
using std::cin;
using std::endl;
void encrypt()
{
char input[15];
int counter = 0;
int newletter;
//char test[22];
system("CLS");
do
{
cout << "Please enter a word to encrypt:\n>";
cin >> input;
if(input[14] != '\0')
{
input[14] = '\0';
}
}while(input[14] != '\0');
//cin.clear();
//cin >> test;
while(counter <= 13)
{
if(!(input[counter] >= 32 && input[counter] < 125))
{
break;
}
newletter = input[counter];
input[counter] = ++newletter;
counter++;
}
cout << "your encrypted word is:\n" << input << endl;
//cout << "\n\n\n\n\nTEST: " << test << endl;
system("PAUSE");
//return 0;
}
and in Project 10-3.cpp I have:
#include <iostream.h>
#include <cstdlib>
/*using std::cout;
*using std::cin;
*using std::endl;*/
void decrypt()
{
char input[15];
int counter = 13;
int newletter;
system("CLS");
do
{
cout << "Please enter a word to decrypt:\n>";
cin >> input;
if(input[14] != '\0')
{
input[14] = '\0';
}
}while(input[14] != '\0');
while(counter >= 0)
{
if((input[counter] <= 32 || input[counter] >= 125))
{
counter--;
continue;
}
newletter = input[counter];
input[counter] = --newletter;
counter--;
}
cout << "\nyour decrypted word is:\n" << input << endl;
system("PAUSE");
//return 0;
}
Here's what I've done so far. I have started a new project file under the type "Console Application" -> chosen "C++" for the language -> selected my destination folder -> chosen the compiler type (GNU GCC Compiler) and have selected "Create 'Debug' configuration" and "Create 'Release' configuration" (choosing the default settings for both of these) -> and then I selected "main.cpp" and put in what you see in the code above. Can someone help me through getting the compiler to see the other two programs? I'd like to learn how to do this for future reference.
ALSO: This project is not an assignment. the two programs (project 10-2/project 10-3.cpp) were assignments, but have been turned in already, as they're working the way I want them to.