Reputation: 55
I'm supposed to use a function and structs to create a program that allows the user to input a list of passwords and a list of password hints and only one of them is the correct one. You're supposed to match your hints with the possible passwords that you have inputted and determine the correct password from there. Here's a sample run:
Input:
3
password
secret11
qwertyui
Output:
4
*******1
s*******
*e******
*******q
secret11
Here is what i have so far:
#include <stdio.h>
#include <string.h>
struct Option {
char password[50];
int matches;
};
// Checks to see if the given password matches the given pattern.
// Returns false (0) if it does not, or true (1) if it does.
int is_match(char password[], char pattern[]){
}
int main(){
int N,i;
printf("Enter the N value\n");
scanf("%d", &N);
struct Option A[100];
for(i=0; i<N; i++);{
scanf("%s", &A[i].password);
}
int M;
scanf("%d", &M);
//struct Option A[100];
int j;
for(j=0; j<M; j++);{
scanf("%s", &A[i].matches);
}
return 0;
}
My program stops at the first scanf and only lets me input two of the passwords. I don't know how to debug at this step.
Upvotes: 0
Views: 1171
Reputation: 1851
Remove the semicolon after your for loop conditions:
for(i=0; i<N; i++)
{
scanf("%s", &A[i].password);
}
that's a start anyway.
Upvotes: 1