Directory user and pass creation





6
Somewhat simple C++ program I wrote with the help of some people at the Cprogramming Message Board. Basically, it takes user input for a username and password, and creates a directory in C:/Program Files/Program/ with a file containing username and a file containing password.

Part of my coding for a program I am creating...

FlyingIsFun1217


//headers placed here...
#include <iostream>
#include <fstream>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>

using namespace std;

int main()
{

    {
    std::string newusername;
    std::string newuserpassword;
    std::string newDir="C/Program Files/program/"+newusername;
    }

    {

    cout<<"Please enter a user name to use (one word only, 30 letters): ";
    cin>>newusername;
    cin.ignore();

    cout<<"\n"<<newusername<<" is now being used as your username.\n\n";
    cout<<"Enter a password to use for "<<newusername<<"'s account: ";
    cin>>newuserpassword;
    cin.ignore();

    cout<<"\nPlease wait while your account ('"<<newusername<<"') is created...";
    cout<<"\n\nCreating User Folder...";

    mkdir("C:/Program Files/program/");
    mkdir(newDir.c_str());

    cout<<"\nCreating Username File...";

    {
    ofstream usernamecreate;
    usernamecreate.open("C:/Program Files/program/username.txt");
    usernamecreate<<newusername<<endl;
    usernamecreate.close();
    }

    cout<<"\n"<<newusername<<"'s User Name file successfully created!...";

    cout<<"\nCreating Password File...";

    {
    ofstream userpasswordcreate;
    userpasswordcreate.open("C:/Program Files/program/password.txt");
    userpasswordcreate<<newuserpassword<<endl;
    userpasswordcreate.close();
    }

    cout<<"\n"<<newusername<<"'s Password saved successfully!...";

    cout<<"\n\nDone!";
    cout<<"\n\nYour User Name is '"<<newusername<<"' and your password is     '"<<newuserpassword<<"'.\n"
          "Make sure that you know these, as there is no way of retirieving\nthis information.";
    cin.get();
}

 

Comments

There are currently no comments for this snippet.

Voting