codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  C++ and Passwording Files  intel17 at 11:14 on Tuesday, February 21, 2006
 

Right this will be my first C++ Programme. I would like to create a programm that will ask the user for a pass number and then if they give the correct pass number, they will be able to se the files (or atleaset Bring up the files) and if they have got the number wrong, then it will write it to a log.

so far I have created an "if" statment, so that when the user enters "23" it says "{cout<<"you got it right, welcome to my Files\n";" and if they get it wrong it writes it to a file but the file only writes it once

What I would Like to know is how do I get it that when the user enters the correct number it will bring up the files in windows, like say "My Documents" or just issue a command into Command Prompt.

here is the Code:


#include <iostream>
#include <fstream>

using namespace std;

int main()
{
int thisisanumber;

cout<<"Please enter pass number: ";
cin>> thisisanumber;
cin.ignore();
if ( thisisanumber == 23 ) {cout<<"you got it right, welcome to my Files\n";
}

else if ( thisisanumber != 23 ) {
cout<<"Denied!\n"; {
ofstream myfile ("/forum/example.txt");
if (myfile.is_open())
{
myfile << "" << thisisanumber << " is not the Number!\n";
myfile << "Atempt Denied\n";
myfile << "--------------\n";
myfile.close();
}
else cout << "Unable to open file"; }
}
cin.get();
return 0;
}


Thanks for reading,
Pete

<Added>



#include <iostream>
#include <fstream>

using namespace std;

int main()
{
int thisisanumber;

cout<<"Please enter pass number: ";
cin>> thisisanumber;
cin.ignore();
if ( thisisanumber == 23 ) {cout<<"you got it right, welcome to my Files\n"; // this is where i would like it to issue a command promt command, if that is possible
}

else if ( thisisanumber != 23 ) {
cout<<"Denied!\n"; {
ofstream myfile ("/forum/example.txt");
if (myfile.is_open())
{
myfile << "" << thisisanumber << " is not the Number!\n";
myfile << "Atempt Denied\n";
myfile << "--------------\n";
myfile.close();
}
else cout << "Unable to open file"; }
}
cin.get();
return 0;
}




<Added>

I am useing Dev-C++ Beta








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  I NEED HELP!!!!!!!!
•  JavaScript & PDF
•  Re: Help !Sorting Problem !!!
•  Re: Jbutton events
•  Re: im trying to sort my program with insertionSort and selectionSort
•  trouble with literal
•  Re: need help
•  How to go from a novice to a senior/Tech lead/architect etc in short span of time?
•  Java Speech API (JSR 113)


Recent Articles
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net
Creating CSS Buttons


© Copyright codetoad.com 2001-2006