無題
Posted: 2007年11月08日(木) 22:33
顧客マスタファイルを作っています。ポイントカードがあり、発行した日から一年間有効なものにしています。発効日と期限日は構造体を使用しています。うるう年の場合の計算も入れたつもりです。ポイントカードの期限が切れたら、顧客コードは変えずに新規発行するシステムです。コードはcushファイルのc_codeと比較して、なかったら新規発行にしています。ポイントは別なファイルで処理し、そこから持ってきます。(cushファイルのc_pointに入っています)作り方がまったく分からなく、ここから進めません。よろしかったら教えてください。
/*顧客マスタファイル cust.dat*/
#include <stdio.h>
#include <time.h>
int date(int );
void main()
{
struct kokyaku
{
int k_code;
short h_nen,h_tsuki,h_hi;
short k_nen,k_tsuki,k_hi;
}kokyaku;
FILE *cf;
int k_point=0;
int dt,year,month,day;
printf("今日の日付を入力(YYYY MM DD):");
scanf("%d %d %d",&kokyaku.h_nen,&kokyaku.h_tsuki,&kokyaku.h_hi);
year=kokyaku.h_nen;
month=kokyaku.h_tsuki;
day=kokyaku.h_hi
dt=date(int year,int month,int day);
}
int date(int year,int month,int day)
{
int k_year,k_month,k_day,pt;
kokyaku.k_nen=(kokyaku.h_nen)+1;
if((kokyaku.h_tsuki==3) && (kokyaku.h_hi==1)){
if((kokyaku.k_nen%4==0) && (kokyaku.k_nen%100!=0)){
kokyaku.k_tsuki=kokyaku.h_tsuki-1;
kokyaku.k_hi=29;
}else{
kokyaku.k_tsuki=kokyaku.h_tsuki-1;
kokyaku.k_hi=28;
}
}else if(kokyaku.h_hi==1){
kokyaku.k_tsuki=kokyaku.h_tsuki-1;
kokyaku.k_hi=kokyaku.h_hi;
}
cf=fopen("../datafile/cush.dat","r");
while((kokyaku.k_code) == c_code){
if((kokyaku.k_code)!=EOF){
dt=date();
}else if((kokyaku.k_nen) < (kokyaku.h_nen) || (kokyaku.k_tsuki) < (kokyaku.h_tsuki) || (kokyaku.k_hi) < (kokyaku.h_hi))
k_point=0;
}
}
k_year=kokyaku.k_nen;
k_month=kokyaku.k_tsuki;
k_day=kokyaku.k_hi;
pt=k_point;
return (k_year,k_month,k_day,pt);
}
/*顧客マスタファイル cust.dat*/
#include <stdio.h>
#include <time.h>
int date(int );
void main()
{
struct kokyaku
{
int k_code;
short h_nen,h_tsuki,h_hi;
short k_nen,k_tsuki,k_hi;
}kokyaku;
FILE *cf;
int k_point=0;
int dt,year,month,day;
printf("今日の日付を入力(YYYY MM DD):");
scanf("%d %d %d",&kokyaku.h_nen,&kokyaku.h_tsuki,&kokyaku.h_hi);
year=kokyaku.h_nen;
month=kokyaku.h_tsuki;
day=kokyaku.h_hi
dt=date(int year,int month,int day);
}
int date(int year,int month,int day)
{
int k_year,k_month,k_day,pt;
kokyaku.k_nen=(kokyaku.h_nen)+1;
if((kokyaku.h_tsuki==3) && (kokyaku.h_hi==1)){
if((kokyaku.k_nen%4==0) && (kokyaku.k_nen%100!=0)){
kokyaku.k_tsuki=kokyaku.h_tsuki-1;
kokyaku.k_hi=29;
}else{
kokyaku.k_tsuki=kokyaku.h_tsuki-1;
kokyaku.k_hi=28;
}
}else if(kokyaku.h_hi==1){
kokyaku.k_tsuki=kokyaku.h_tsuki-1;
kokyaku.k_hi=kokyaku.h_hi;
}
cf=fopen("../datafile/cush.dat","r");
while((kokyaku.k_code) == c_code){
if((kokyaku.k_code)!=EOF){
dt=date();
}else if((kokyaku.k_nen) < (kokyaku.h_nen) || (kokyaku.k_tsuki) < (kokyaku.h_tsuki) || (kokyaku.k_hi) < (kokyaku.h_hi))
k_point=0;
}
}
k_year=kokyaku.k_nen;
k_month=kokyaku.k_tsuki;
k_day=kokyaku.k_hi;
pt=k_point;
return (k_year,k_month,k_day,pt);
}