Username and password

I am not a programmer by any means, but for my class we havto do this:

Write a program that asks the user to create a username and password for a logon account. Both should be held as a cString. Prompt the user to enter his/her information to “log on” to an account. The username is not case sensitive, but the password is – only display a successful log on message if both pieces of information are entered according to this constraint. After a successful logon, the username in all lowercase letters should be displayed and the password should be shown as a number of ‘*’ equal to the length of the password.

Here's my code so far, and unless someone in my class explains every bit and snip of code that is required, I cannot understand anything.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	char username[11];
	char password[11];

	int profile = 0;

	cout << "Create a username and password: " << endl;

	while (profile == 0) //set to '0' by default
	{
		int checkusername = 0; //set to '0' until the condition is met
		int checkpassword = 0; //set to '0' until the condition is met

		cout << "Enter your username (Up to 10 characters, letters and numbers only!)" << endl;
		cin >> username;

		cout << "Enter your password (Up to 10 characters, letters and numbers only!)" << endl;
		cin >> password;

		//check if the lenght is equal to required size
		if (strlen(username) > 10)
		{
			checkusername = 1;
		}
		else
		{
			for(int i = 0; i < strlen(username);i++)
			{
				if (isalnum(username[i]))
					continue;
				else
				{
					checkusername = 1;
					break;
				}
			}
		}

		//check if password is appropriate leght
		if (strlen(password) > 10)
		{
			checkpassword = 1;
		}
		else
		{
			for(int i = 0; i < strlen(password);i++)
			{
				if(isalnum(password[i]))
					continue;
				else
				{
					checkpassword =1;
					break;
				}
			}
		}


	//End of While Loop//
	}

	

return 0;
}
bump?
Topic archived. No new replies allowed.