Comparing pre-stored data

Hello,
I need to write a program that can firstly create user account and store the information ( ID & Password ) and secondly, compares the login data which the user input with pre-stored data.

And i seems to have problem in comparing the login data.
The [b]underline[/b] part doesn't seem to be working as i keyed in the correct input but it doesn't go into the ' if ' statement.

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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include<stdio.h>
void main()
{
	char username[100][31], password[100][31],usercheck[31],passcheck[31];
	int  count=0, index=0;
	int  option;
	char Y='y';
	int  N;
    
    
    printf("======Password auto-generation and validation ====== \n");
	do
	{
		printf("1)Create the user account< username+password> \n");
		printf("2)Validation of login ID and password \n");
		printf("3)Password auto-generation. \n");
		printf("4)Exit \n");
		printf("============================================================ \n");
		printf("Enter your option: \n");
		flushall();
		scanf("%d" , &option);
		if(option==1)
		{
			
				printf("Please type in user ID: \n");
				flushall();
				gets(username[index]);
				printf("Please type in your password: \n");
				gets(password[index]);
				do
			{
				printf("Do u want to create more user?(Y/N) \n");
				scanf("%c" , &Y);
				if(Y=='y') 			
				{
					index++;
					printf("Enter a username for user[%d]: \n",index+1);
					flushall();
					scanf("%s",username[index]);
					
					printf("Please enter a password: \n");
					flushall();
					gets(password[index]);
				}
		   }while(Y=='y');
		}

		if(option==2)
		{
				count=0;
					do
					{
						index++;
						printf("Enter your user name:");
						flushall();
						gets(usercheck);
						do
						{
							if(username[index]==usercheck)
							{
								printf("Enter the password\n");
								gets(passcheck);
								
							}
							else
							{
								index++;
								if(index>100)
									printf("Invalid username. Please enter again\n");
						    }
						}while(usercheck!=username[index] && index<=100);
					}while(index>100);
					if(passcheck==password[index])
					{
							printf("Password check: Pass\n");
					}	
					else
					{
							do
							{
								printf("Password is not VALID, you may try again.");
								printf("Enter the password\n");
								gets(passcheck);
								count++;
							}while(count<3 && passcheck!=password[index]);
							if(count==3)
								printf("You have tried 3 times already, no more attempts are allowed!");
							if(passcheck==password[index])
								printf("Password check: Pass\n");
				}
		}
	}while(option != 4);
}
You cannot compare C strings with operator==, you'll need to use strcmp.
First you should transform your code into C++ code. This is pure (and incorrect) C code, so this is the wrong site to post on.
Topic archived. No new replies allowed.