密码恢复程序

时间:2015-04-15 15:28:27

标签: c

我应该使用一个函数和结构来创建一个程序,允许用户输入一个密码列表和一个密码提示列表,其中只有一个是正确的。您应该将您的提示与您输入的可能密码相匹配,并从那里确定正确的密码。这是一个示例运行:
输入:
3
密码
secret11
qwertyui
输出:
4
******* 1个
小号*******
* E ******
******* q
secret11

这是我到目前为止所拥有的:

#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;
}

我的程序在第一次扫描时停止,只允许我输入两个密码。我不知道如何在这一步调试。

2 个答案:

答案 0 :(得分:1)

在for循环条件后删除分号:

   for(i=0; i<N; i++)
   {
        scanf("%s", &A[i].password);
   }
无论如何,这是一个开始。

答案 1 :(得分:-1)

在每fflush(stdin);之前使用scanf()