Hello Friends,
I'm new to C++ coding and trying to built a small program which will ask user to login with the specific username and password and after successful login, user get the options of writing a new file or opens any previously written file and also gets option to encrypt his file.
I also want that if the person has entered wrong password thrice, then the files written previously through the program should get encrypted and decryption will be done later after verification of the user.
I have developed the first half i.e. login and reading and writing of file, and getting no clue about how to implement the remaining half.
PLEASE GUIDE ME ON HOW CAN I MAKE THE REST HALF and also I'm getting few errors in the code I've made, it in not working properly....
Please review this code
NOTE :: I have a compulsion of making this program in turbo c++ only, so please help me out.
Here is my complete code that i have developed
Thank you very much in advance, I will highly appreciate your help
Please remember that string are terminated with '\0' so you need to define the length one longer.
Also it would be better to use a type of constant for the length like
If I'm using any function like strcmp() or stricmp() in turbo c++, it is showing error as "strcmp() should have a prototype" and same error in stricmp also.
and also, program is never getting inside if condition, either it is not comparing the strings and directly displaying the switch case otherwise, it is getting inside else loop every time
case 2:
{
cout<<"enter file name to open ";
cin>>fname;
if(lock==1)
{
cout<<"sorry..this file is locked.\n Want to unlock? press 1 ";
cin>>yes;
if(yes==1)
{
cout<<"enter unlock code ";
cin>>code;
if(code==mycode[12])
{
lock=0;
}
else
cout<<"wrong code";
return 0;
}
elsereturn 0;
}
char line[1000];
cout<<"Enter File name: ";
cin>>fname;
ifstream myfile(fname);
while (myfile.eof())
{
cout << line << '\n';
myfile.close();
}
}
EDIT: One thing that becomes easier to see with a sensible layout, is that if the file is locked, the function will exit without opening and reading the file, regardless of whether the user enters 1 or not.
actually, i want it to read and write files after user login (successful login) and also to hide data written in files if user wants i.e. after complete writing of file, if user want to encrypt the data then he could.
and if in case user fails to login correctly for consecutively 3 times, it must encrypt ll the files written via this program should get encrypted and decryption will be done after verification.
presently, it is doing the login process successfully and even writing the file as required but while it comes to load any file, the process terminates (even the file is not locked) and the available commands list is displayed again and it asks for user to input command to weather to write or load a file or to exit the program.
and talking about locking of any file, once the programs exits and you starts it again, lock value again gets to 0 i.e. all locked files are unlocked now, tough, later on, i will not use this lock method instead i will ask user to encrypt the file or not.
but actually, when I'm giving input as 1, it is writing file and after saving the file as per the given name, case 2 and case 3 are automatically starting and all the cout << "" are displayed by default
if user select 1, case 2 and 3 also gets starts after case 1 ends and if user selects 2, case 3 starts after ending case 2, the similar process is continuing