Here it is know. It still isn't createing a txt file.
Code:
#include <fstream.h> //include everything that is nessacary
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
void login()
{ char nuttin[2];//initialize my variables
char read[10];
char siname[10];
char sipass[10];
char txt[10];
cout<<"Please Enter Your User Name:\t";//ask for a user name
cin>>siname;//write the name to siname
strcpy(siname,txt);
strcat(txt,".txt");
ifstream d_file(txt);//open username.txt
cout<<"Please Enter Your Password:\t";//ask for a password
cin>>sipass;//write the password to sipass
strcat(siname, ".");//add a period at the end of siname
strcat(siname, sipass);// combine the two to create a variable contiaining "username.password"
d_file>>read;//write the contents of username.txt to a variable
if (strcmp(read,siname) == 0) //compare the variables
{ cout<<"You Have Succesfully Logged In:\n";//explain the login was successful
system("PAUSE");//end the program
}
else
{ cout<<"\nYour Log In Was Unsuccessful.Quit. Then Restart The Program To Try Again Or Sign Up\n";
//explain something went wrong and give directions on what to do
system("PAUSE");//end the program
}
}
void signup()
{
char name[10],pass[10],filename[12],combo[20];
cout << "Enter 8 character user name:";
cin >> name;
cout << "Enter 8 characater password:";
cin >> pass;
strcpy(filename,name);
// in string.h copys one string to another instead of doing
//filename=name; which doesn't do what you want or think it does
strcat(filename,".txt");
strcpy(combo,name);
strcat(combo,".");
strcat(combo,pass);
cout<<"\n\nYou Have Successfully Signed Up.\n\n";
system("PAUSE");
}
int main()
{ int k;
cout<<"\t\t******** Welcome to Login Program *********************";//some pretty ouput to tell them where they are
cout<< "\n 1: LOGIN\n 2: SIGN UP\n 3: EXIT\n Please Make your Choice:";//output their choices and ask for theirs
cin>>k;//input their choice and write it to k
if (k==1)//cheak if k=login
{ login();//if it does then execute the login function
}
else if(k==2) //see if k= signup
{ signup();}
else if(k==3)
{return 0;}
}