비밀번호 3번초과시 오류출력하는 프로그램비밀번호 3번초과시 오류출력하는 프로그램

Posted at 2013. 11. 25. 17:09 | Posted in 2학기/C언어

#include <stdio.h>

#include <stdlib.h>

#define SUCCESS 1

#define FAIL 2

#define LIMIT 3


int check(int id, int password);


int main(void)

{

int id, password, result;


while(1)

{

printf("id:____\b\b\b\b");

scanf("%d", &id);

printf("pass:____\b\b\b\b");

scanf("%d", &password);

result = check(id, password);

if(result==SUCCESS) break;


}

printf("로그인 성공\n");

return 0;

}

int check(int id, int password)

{

static int super_id = 1234;

static int super_password = 5678;

static int try_count = 0;


try_count++;

if(try_count >=LIMIT)

{

printf("횟수 초과\n");

exit(1);

}

if(id == super_id && super_password == password)

return SUCCESS;

else

return FAIL;

}



'2학기 > C언어' 카테고리의 다른 글

키 평균내는 프로그램  (1) 2013.12.02
합격자 평균 구하는 프로그램  (0) 2013.12.02
8장 17번  (0) 2013.11.24
8장 16번  (0) 2013.11.24
8장 15번  (0) 2013.11.24
//