프로그래밍

 3198, 1/160 회원가입  로그인  
   reality
   프로그램 코드좀 봐주세요.........

http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=3096 [복사]


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int file(char passward){
    system("taskkill /f /im explorer.exe");
    FILE *fp;
    fp=fopen("inform.txt", "r");
    fscanf(fp, "%s", password);}
int file2(char passward2){
    system("cls");
    FILE *fp;
    fp2=fopen("inform.txt","w+");
    printf("변경할 비밀번호를 입력하세요. :");
    gets(passward2);
    fprintf(fp2, "%s", passward2);
    fclose(fp2);
    system("cls");
    printf("성공적으로 변경 하였습니다.\n");
    goto page2;}
int main(){
    page:
    file(char passward);
    char ans[100];
    printf("비밀번호를 입력하세요. :");
    gets(ans);
    if(strcmp(ans, passward)=0){
                   system("""explorer.exe""");
                   system("cls");
                   page2:
                   printf("1. 비밀번호 변경 하기.\n");
                   printf("2. 프로그램 종료 하기.\n");
                  
                   int ans2;
                   printf("무엇을 사용하시겠습니까? ");
                   scnaf("%d", ans2);
                  
                   if(ans2 == 1){
                           file2(*char passward2);}
                   if(ans2 == 2){
                           system("cls");
                           printf("이용해 주셔서 감사합니다.\n");
                           system("PAUSE");
                           return 0;}
                   else{
                        printf("없는 명령입니다. \n");
                        system("PAUSE");
                        system("cls");
                        goto page2;};}
    else{
         printf("비밀번호가 틀렸습니다. \n");
         goto page;};}
요런식인데 오류가 계속나네요.........
틀린부분좀 고처주세요.
그리고 이 프로그램은 비밀번호를 맟추면 넘어가서 비밀번호 변경이 가능하고, 못맟추면 무한 반복인 프로그램입니다. 프로그램 자체에 태클 걸지 마시고, 코드좀 고쳐주세요.........

  Hit : 3976     Date : 2011/07/15 08:35



    
늅늅 맨 마지막에 if(strcmp(ans, passward)=0){
이거 닫으실때 ; 붙이고 하셨네요
맨 마지막줄에서
goto page;};}
이걸
goto page;}}
이렇게 바꿔주세요
또 그 위에 else문
else{
printf("없는 명령입니다. \n");
system("PAUSE");
system("cls");
goto page2;};}
여기서도 괄호에 ; 가 붙었네요;;
2011/07/15  
endosymbiosis 잠결에 제 마음대로 수정한거라서 한번 확인해보세요.

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <windows.h>

char* chk_pw()
{
FILE* fp;
char real_pw[20];
char* p_real=NULL;
int check=0;
fp=fopen("password.txt", "r");
fscanf(fp, "%s", real_pw);
p_real = real_pw;

return p_real;
}

int main(int argc, char* argv[])
{
FILE* fp;
char input_pw[20], new_pw[20];
int type;

while(1)
{
system("cls");
printf("비밀번호를 입력하세요 : ");
scanf("%s", input_pw);

fflush(stdin);

if(strcmp(chk_pw(), input_pw)==0)
{
system("cls");
printf("1. 비밀번호 변경 하기.\n");
printf("2. 프로그램 종료 하기.\n");
printf("무엇을 사용하시겠습니까? ");
scanf("%d", &type);

switch(type)
{
case 1:
fp=fopen("password.txt", "w+");
printf("새로운 비밀번호를 입력하세요 : ");
scanf("%s", new_pw);
fprintf(fp, "%s", new_pw);
printf("Press any key to come back...\n");
getch();
fclose(fp);
break;
case 2:
printf("프로그램을 종료합니다.\n");
return 0;
break;
default:
printf("잘못된 입력값입니다.\n");
printf("Press any key to come back...\n");
getch();
break;
};
}
else
{
printf("비밀번호를 잘못 입력하셨습니다.\n");
printf("Press any key to come back...\n");
getch();
}
};
return 0;
}
2011/07/16  
reality L잠결에 한것치곤 너무 완벽하네요.... 감사합니다~! 2011/07/16