password script

I have a simple password program that I would like to put into some other programs. Is there a way to have the code of program B run the password program at the beginning of the code?
Put it at top:
1
2
3
4
5
6
7
8
9
10
11
12
string password ;
string correctpassword="Pie" ;
cout<<"Please enter password." <<endl ;
cin>> password ;
if (password=correctpassword)
{
   //do your program
}
else
{  
   cout<<"Sorry wrong password." <<endl ;
}

well I know in shell scripting you can just put ./(program) in the code to get it to run. Is there a way to do this in C++?
...there is, but it's a bad habit to rely on it in C++. Instead of using std::system(), why not create a function?
http://cplusplus.com/doc/tutorial/functions/

-Albatross
Topic archived. No new replies allowed.