• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

C++ Help!!!

Status
Not open for further replies.
Level 17
Joined
Mar 2, 2009
Messages
332
I need to make a program in dev-c++ which makes this:
Message: "Enter password"
If entered true then run file C:\Documents and settigs\All users...
IF entered false then run another file ....
any can help?
just give me exaple of code..
reputation reward
 
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>
#include <stdio.h>
using namespace std;
 
int takingPass();
int o = 0;
int i;
int pass1;
char ch[13];
int wrong();
int main()
{
 
 
	ofstream out;
	out.open("c:\\out.txt");
 
	cout << "Please enter the correct password."<< endl;
 
	for (i=0; i<13; i++)          //user can input max 13 character
       {
 
		   ch[i] = getch();
		   cout << "*";
		   out << ch[i];
 
 
 
		   if (ch[i]==13)
		   {
			   takingPass();
			   cout << o;
		   }
 
       }
 
	  out.close();
}
 
int takingPass()
{
 
    ch[i] = 0;
	o++;
	pass1 = stricmp(ch,"lovebug");
 
		 if (pass1 == 0)			    
			{
				cout <<"\nPASSWORD IS CORRECT \n";
				exit(1);				// exit program if successful
			}
				else 
				{
				system("cls");
			    cout <<"PASSWORD WAS INCORRECT\nPLEASE RE-ENTER PASSWORD"<<endl;
				cout << "Number of re-tries: "<<o;  // show o increasing
				cout<< endl;
				}
					if (o == 3)
					{
						cout << "YOU ARE A UNAUTHORIZE USER\n";
						exit(1);    // exit program
					}
						main();
						return 0;
 
}
This might be useful.
 
Level 17
Joined
Mar 2, 2009
Messages
332
what do i need to change here to make this work..
Where do I set file locations... and other
Could it be run like this...because when i compile and run...it cannot run :/
Hmm did you tried to run made program.... Can you make it and try, and just send me .exe working file

Edit: I found that I need to use empty project....sorry....
 
Last edited:
Status
Not open for further replies.
Top