hello ,
i am starting to program my project in c++
i need help in direction.
my project is like wikpedia . i should enter about 3 value in each catagory (3*7) .
the search will be by pressing some value and then a list will open with all the value that it found. choice will happen by pressing a number (1-5) and there will be another botton (6) that will send to another page with more choices.
the user can typing a value and the pc will ask if it is the value he want if Y he will show the value
if N he will open the search window again.
pressing Y will enter the user to a window that show :
1. free search: a. the exect value.
b. at least 1 word.
2.serch by category .
3. random search the pc will found randomly value and then he will ask if the user want this value.Y will enterr N will cancel and go to the search again.

creat an account:
by fill in private details , USER NAME , passwor (6 numbers), question for restore the password
3 incorect pass typing will bring to an exit
there be an restore password option.

the value name will be bold and with color and the other txt will not.

i wrote the begening code
i have some problam :
1) when im pressing 'C' he show me an error , he say that question and answer allready in use.
2) for exemple: when im pressing Y or N in the 'Q' option he do nothing. and show the press any key to continue.
3)how do i program an option to do an accountt? how the password will show like ********
4) how do i program that if i press little letter q instade of Q he will recognize it like Q ?


this is the code:

/* search_engine */

#include <iostream>
#include <string>
using namespace std;

void log_in (string name , string  password);
void creat (string name , string password , float question , float answer );


int main(int argc, char* argv[])
{

    char choice ;
    string name, password;
    int quit;
    float question, answer; 
     
   cout <<"\n\t\t-----------------------------------------";
   cout << "\n\t\t Hello Guest! Welcome to search engine!\n";
	cout<<"\t\t-----------------------------------------\n";
   cout << "What would you like to do: \n\n";
   cout << "[L]og In \n"  << "[C]reat an account \n" ;
   cout << "[G]uest \n"  << "[Q]uit \n\n";
   cout <<"Press a letter (L , C , G , Q): "; cin >> choice; 
   
   switch (choice)
   {
        case 'L': log_in (name , password) ; break;
        case 'C': creat (name ,password , question,  answer); break ;
        case 'G': cout <<"\n\t\t\t\t-----\n"; cout <<"\t\t\t\tGuest\n"; 
			         cout<<"\t\t\t\t-----\n"; break;
        case 'Q': cout << "Are you sure you want to exit the program? Y/N \n"; cin >> quit;
            if (quit == 'Y' )
            exit (0) ;
            else choice ; break;
   }
   return 0;
}


void log_in (string name, string password)
{
    cout <<"\n\t\t\t Log in for an existing account. \n\n";
	 cout << "User Name: ";
    getline (cin,name); cout <<'\n';
	 cout <<"Password: ";
    cin >> password; cout <<"\n\n";
    cout <<"Welcome Back " << name; cout <<"\n\n";
    cout << "Press [H]istory to view your search history";
}

void creat (string name , string pass , float question , float answer )
{
   cout <<"\n\t\t\t Creat an account. \n";
   cout <<"\t\t Please fill in the following questions \n";
   cout <<"User Name:";
   getline (cin,name); cout <<'\n';
	cout <<"Password (6 numbers max):\n";
   cin >> pass; cout <<'\n';
   cout <<"Re-type your password: ";
   cin >> pass; cout <<'\n';
   cout <<"Question to restore your password: ";
   cin >> question; cout <<'\n';
   cout <<"Answer: ";   
   cin >> answer ; cout <<'\n';
}

any help will welcome!!

while im enter 'L' or 'C' the program won't let me enter the user name and it move direct to the password.
how do i do that the program ask me user name and after i pressing the user he will ask me the password

I think your problem with the user name is that you are using getline. Try just using cin >> name; , like you're doing with the password.

As for reading the password in as *'s, as far as I know (though I could be wrong) there is no clean way to do this in C++. If you are on a UNIX environment, you should be able to play around with the termios APIs to get it to work.

thanks.
but , i do know there is a way printing ***
the getline is for the string so i can print a user with spaces

Regarding the password masking with asterisks, yes it is doable (we've all seen it), but the question is "Can it be done using only the standard libraries?" I don't know the answer to that, but googling "C++ password masking" yields some good threads and the answers tend to lean towards "no". Most of them suggest using getch() from conio.h, which isn't a standard library. You'll have to decide whether you care about only using the standard libraries. If you have access to getch() or an alternative to it and don't care about the portability problems, then that's your best bet. There are loads of examples out there using getch ():

http://www.google.com/#hl=en&source=hp&q=c%2B%2B+password+masking+getch&btnG=Google+Search&aq=f&aqi=&oq=c%2B%2B+password+masking+getch&fp=e8d6ef47431c6a4a

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.