summaryrefslogblamecommitdiffstats
path: root/util/openvice.c
blob: b622eb55189df9962b09d72c864960e0c2ef1b4f (plain) (tree)
1
2
3
4
                                                         

                    
                
















                                                                   

                   
                       





















                                                                                   
/* $Id: openvice.c,v 1.2 2002/06/06 21:34:14 in2 Exp $ */
/* 發票開獎小程式 */

#include "bbs.h"

#define VICE_SHOW  BBSHOME "/etc/vice.show1"
#define VICE_BINGO BBSHOME "/etc/vice.bingo"
#define VICE_NEW   "vice.new"
#define VICE_DATA  "vice.data"
#define MAX_BINGO  99999999

int main()
{
    char TABLE[5][3] =
    {"一", "二", "三", "四", "五"};

    int i = 0, bingo, base = 0;


    FILE *fp = fopen(VICE_SHOW, "w"), *fb = fopen(VICE_BINGO, "w");

    resolve_utmp();

    srand(SHM->number);

    if (!fp || !fb )
    perror("error open file");


    bingo = rand() % MAX_BINGO;
    fprintf(fp, "%1c統一發票中獎號碼\n", ' ');
    fprintf(fp, "%1c================\n", ' ');
    fprintf(fp, "%1c特別獎: %08d\n\n", ' ', bingo);
    fprintf(fb, "%d\n", bingo);

    while (i < 5)
    {
    bingo = (base + rand()) % MAX_BINGO;
    fprintf(fp, "%1c第%s獎: %08d\n", ' ', TABLE[i], bingo);
    fprintf(fb, "%08d\n", bingo);
    i++;
    }
    fclose(fp);
    fclose(fb);
    return 0;
}