Hi I am working on a program that asks the user to create an account and verifies if the account is already registered. I figured out that I can do this by storing the input value in an array. I was wondering if anyone can teach me how I can store an input value in an array and how to I verify if it was already entered. I hope I am not asking for too much.
First the variable is dependent on what you making it. Say if the user input is a 5 digit account number account.
First you have to declare how many account numbers there are. Without going into pointers and how create a dynamic array lets say there is only five people who have registered there account and we know there is only is only 5 people registered.
so....
1 2 3 4 5 6 7 8 9 10 11 12 13
int temp, count;
int account [5]; //This declares the array with 5 spots.
int account [0] = 22134; // This declares the first number in the array to be 22134
cout << "Please insert account number."
cin >> temp;
for (count = 0; count < 5; count++)
{
if (account [count] == temp)
{
cout << "this is an account number";
}
}
Keep in mind this code isn't really what your trying to accomplish, but it kinda gives the idea of how to declare a static array, how put something inside of the array, and how to compare the values in a array with a different value. Furthermore, I would strongly suggest reading the c++ page on array's and checking out some tutorials on youtube. Here the page on arrays.