当前位置:编程学习 > C/C++ >>

c语言问题(编程问题)

#include<stdio.h>
#include<stdlib.h>
#define SIZE 3
#include<string.h>
#include <time.h>

int main()
{void cxxtsj( );
struct gongzguanli;
int gzcx();
void save();
gzcx();
cxxtsj( );

save();
}

struct gongzguanli
{char name[10];
char    gz[8] ;                                          //gz是工种
int age;                                            //gh是工号,jbgz是基本工资,gwgz是岗位工资,bxf是保险费,sfgz是实发工资,gzze是工资总额
int gh;
int jbgz;
int gwgz;
int bxf;
int sfgz;
int gzze;
}gong[SIZE];

void cxxtsj( void )
{
struct tm *newtime;
char am_pm[] = "AM";
time_t long_time;

time( &long_time ); /* Get time as long integer. */
newtime = localtime( &long_time ); /* Convert to local time. */

if( newtime->tm_hour > 12 ) /* Set up extension. */
strcpy( am_pm, "PM" );
if( newtime->tm_hour > 12 ) /* Convert from 24-hour */
newtime->tm_hour -= 12; /* to 12-hour clock. */
if( newtime->tm_hour == 0 ) /*Set hour to 12 if midnight. */
newtime->tm_hour = 12;
printf("\n");
printf( "                     你查询的时间是:%.19s %s\n", asctime( newtime ), am_pm );
}

 

int gzcx()
{int i,a,b,c;
char name[10]={0};
FILE *fp;
if((fp=fopen("H:\\程序\\工资管理数据.dat","rb"))==NULL)
{printf("无法打开文件\n");
exit(0);
}
printf("%d",&c);
switch(c)
{case 1:
{printf("请输入数据:\n");
for(i=0;i<SIZE;i++)
scanf("%s%s%d%d%d%d%d%d%d",gong[i].name,gong[i].gz,&gong[i].age,&gong[i].gh,&gong[i].jbgz,&gong[i].gwgz,&gong[i].bxf,&gong[i].sfgz,&gong[i].gzze);
save();

}
case 2:
 {printf("                                <工资清单查询>\n\n");
printf("                               查看工号,姓名,工种\n");
printf("\n");
for(i=0;i<SIZE;i++)
{
 fread(&gong[i],sizeof(struct gongzguanli),1,fp);
printf("工号:%d 姓名:%-20s 工种:%-20s\n",gong[i].gh,gong[i].name,gong[i].gz);
}
printf("\n");
printf("            ***************************************\n");
printf("            请输入数字:1:按姓名查询\n                        2:按工号查询\n");

补充:printf(" ***************************************\n");
scanf("%d",&b);

switch(b)
case 1:
{
printf("请输入工号,查看工资清单\n");

printf("\n");
printf("工号:");
scanf("%d",&a);

printf("\n");
printf(" <工资清单数据>\n");
switch(a)
{
{
case 1000:printf(" 工号:%4d\n 姓名:%-20s\n 工种:%-20s\n 年龄:%4d\n 基本工资:%4d\n 岗位工资:%4d\n 保险费:%4d\n 实发工资:%4d\n 工资总额:%4d\n",gong[0].gh,gong[0].name,gong[0].gz,gong[0].age,gong[0].jbgz,gong[0].gwgz,gong[0].bxf,gong[0].sfgz,gong[0].gzze);
;break;
case 2000:printf(" 工号:%4d\n 姓名:%-20s\n 工种:%-20s\n 年龄:%4d\n 基本工资:%4d\n 岗位工资:%4d\n 保险费:%4d\n 实发工资:%4d\n 工资总额:%4d\n",gong[1].gh,gong[1].name,gong[1].gz,gong[1].age,gong[1].jbgz,gong[1].gwgz,gong[1].bxf,gong[1].sfgz,gong[1].gzze);
;break;
case 3002:printf(" 工号:%4d\n 姓名:%-20s\n 工种:%-20s\n 年龄:%4d\n 基本工资:%4d\n 岗位工资:%4d\n 保险费:%4d\n 实发工资:%4d\n 工资总额:%4d\n",gong[2].gh,gong[2].name,gong[2].gz,gong[2].age,gong[2].jbgz,gong[2].gwgz,gong[2].bxf,gong[2].sfgz,gong[2].gzze);
;break;
}

};break;


case 2:
{printf("请输入姓名,查看工资清单\n");

printf("\n");
printf("姓名:");
scanf("%s",name);

for(i=0;i<SIZE;i++)
{

if(strcmp(name,gong[i].name)==0)

{
printf(" 工号:%4d\n 姓名:%-20s\n 工种:%-20s\n 年龄:%4d\n 基本工资:%4d\n 岗位工资:%4d\n 保险费:%4d\n 实发工资:%4d\n 工资总额:%4d\n",gong[i].gh,gong[i].name,gong[i].gz,gong[i].age,gong[i].jbgz,gong[i].gwgz,gong[i].bxf,gong[i].sfgz,gong[i].gzze);

}
}
}
}
}
printf("\n");
printf(" ***************************************\n");
printf(" 但无法查询时,请按要求操作!或者是无此数据!\n");
printf(" ***************************************\n");
fclose(fp);
return 0;
}

void save()
{FILE *fp;
int i;
if((fp=fopen("H:\\程序\\工资管理数据.dat","w+"))==NULL)
{printf("无法打开此文件\n");
return 0 ;
}
for(i=0;i<SIZE;i++)
if(fwrite(&gong[i],sizeof(struct gongzguanli),1,fp)!=1)
printf("file write error\n");
fclose(fp);
}
--------------------Configuration: 程 - Win32 Debug--------------------
Compiling...
程.c
H:\程序\程.c(136) : error C2143: syntax error : missing ';' before 'type'
H:\程序\程.c(138) : error C2143: syntax error : missing ';' before 'type'
执行 cl.exe 时出错.

我抗不住了,找不到!?!

追问:在整个程序的后面

void save()   这里
{FILE *fp;
int i;  还有这里
if((fp=fopen("H:\\程序\\工资管理数据.dat","w+"))==NULL)
{printf("无法打开此文件\n");
return 0 ;
}
for(i=0;i<SIZE;i++)
if(fwrite(&gong[i],sizeof(struct gongzguanli),1,fp)!=1)
   printf("file write error\n");
fclose(fp);
}

 

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,