Putting two pieces of code together help

Just finished some prototypes and looking to put them all together but can't seem to do it, they are completely identical pieces of code with different variable names but I am not able to 'stick' them together, all the program says is that I have redefined a lot of things but without it the program won't work, any help most appreciated.
#include <iostream>
#include <string>
using namespace std;

bool valcheck(string message)
{
int k = 0;
for(int i = 0; i < message.size();i++)
{
if((message[i] < 97 || message[i] > 122) && message[i] != 32)
return false;
}
for(int j = 0; j < message.size();j++)
{
if(message[j] < 122 && message[j] > 97)
k++;
}
if(k == 0)
return false;
return true;

}
int main()
{
string message;
cout << "Please enter a message CONTAINING only letters and spaces" << endl;
getline(cin, message);
for(int i = 0; i < message.size();i++)
message[i] = tolower(message[i]);
while(valcheck(message) == false)
{
cout << "Please try again" << endl;
cout << "Please enter a message CONTAINING only letters and spaces" << endl;
getline(cin, message);
}
cout << "Input Validation Successful" << endl;
cout << message << endl;
return 0;
}
bool valcheck2(string offset)
{
int k = 0;
for(int i = 0; i < offset.size();i++)
{
if(offset[i] < 47 || offset[i] > 58)
return false;
}
for(int j = 0; j < offset.size();j++)
{
if(offset[j] < 58 && offset[j] > 47)
k++;
}
if(k == 0)
return false;
return true;
}
using namespace std;
int main()
{
string offset;
cout << "Please enter an offset CONTAINING only numbers" << endl;
getline(cin, offset);
while(valcheck2(offset) == false)
{
cout << "Please try again" << endl;
cout << "Please enter offset CONTAINING only numbers" << endl;
getline(cin, offset);
}
int numberoffset = atoi(offset.c_str());
numberoffset = numberoffset % 26;
cout << "Input Validation Successful" << endl;
cout << numberoffset << endl;
return 0;
}
Hi,

I am pretty sure you cant use int main() more than once, please read more about functions

http://www.cplusplus.com/doc/tutorial/functions/

just use one int main() and also define function prototype for ease of code :)

HOPE IT HELPS
Topic archived. No new replies allowed.