i have a question is there line of code or any code that restricts the user from inputting any letter or number or any key to my choice, but in a way that when he presses any letter and i restricted the alphabet keys then nothing will happne, or if he tries to press a number nothing will come up on the program, almost as if saying in a way that i turned off the specific keys.

How can I write a program wich print the following output?

**********
**********
**      **
**      ** 
**      ** 
**      **    
**      ** 
**      ** 
**********
**********
commented: What nullptr said! :-( -3

@Solomon bekele, do not hijack someone elses thread. Please start your own thread and provide the code you have written so far.

@neyoibarra, have a look at the functions referenced at http://www.cplusplus.com/reference/cctype/

or if he tries to press a number nothing will come up on the program, almost as if saying in a way that i turned off the specific keys.

Is this to do with your previous post on entering a password? If it is, could you show the code that you currently have, along with the specific restrictions you wish to implement?

Hey NUll PTR well basically i just want a code that will replace the code there on my current if statements in it_rate[count[,it_qty[count], because when i run this program, basically whenever i enter an alphabetic value the program will crach or show an error. i just wanted to find a way to "shutdown" (ill just use that word for now but you know what i mean) the a-z keys (lower and UPPER case) as to just plainly get rid of the stress of having to create multiple if statements.

void getdata()
    {

        cout << "ENTER THE ITEM: ";
        cin >> item[count];
        cout << "ENTER THE ITEM PRICE: ";
        cin >> it_rate[count];
        if (it_rate > 0)
        {
            cout << "only enter a positive integer";
            cout << "please enter data again";
                Sleep(1000);
        }

        cout << "ENTER THE QUANTITY: ";
        cin >> it_qty[count];
        if (it_qty > 0)
        {
            cout << "only enter a positive integer";
            cout << "please enter data again"<<endl;
            Sleep(1000);
        }

        ofstream inven("inventory.txt", ios::app);
        inven << "ITEM" << setw(25) << "PRICE" << setw(7) << "QTY." << endl;
        inven << item[count] << setw(25) << it_rate[count] << setw(5) << it_qty[count] << endl;
        inven.close();

        total[count] = it_rate[count] * it_qty[count];
        it_no[count] = count + 1;
        count++;
    }

I think what you are looking for is 'error handling' for input of 'invalid data' ... so that your running program will NOT then crash ... when the user enters invalid data.

You may like to see this (simple student) example of getting valid integer input from the user:

Click Here

See example 3.

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.