pwdset.c

来自「dos下pos机程序 连接sybase数据库 使用Microsoft c」· C语言 代码 · 共 53 行

C
53
字号
#include <stdio.h>

int main()
{
	//find file
    FILE *fp = 0;
    int pass1 = 0;
    int pass2 = 0;
    int pass3 = 0;
    int flag = -1;
    
    fp = fopen("pwd","w");
    if (fp == 0)
    {
    	printf("can not open file--\"pwd\"!\n");
    }
    
    //set passwod
    while (pass1 < 1 || pass1 > 255)
    {
    	printf("\nplease input the first byte(1-255):");
        scanf("%d",&pass1);
    }//while    
    
    while (pass2 < 1 || pass2 > 255)
    {
    	printf("\nplease input the second byte(1-255):");
        scanf("%d",&pass2);
    }//while    
    
    while (pass3 < 1 || pass3 > 255)
    {
    	printf("\nplease input the third byte(1-255):");
        scanf("%d",&pass3);
    }//while    
    
    flag = fprintf(fp,"%x,%x,%x",pass1,pass2,pass3);
    
    if (flag == -1)
    {
        printf("\nerror in writing data to file--\"pwd\"");
        fclose(fp);
        exit(1);
    }
    else
    {    
        printf("success!");
        fclose(fp);
        exit(0);    
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?