我有错误的按摩,但我不明白是什么问题。我正在寻找这个问题。 我试图创建一个libary函数,并在同一个文件中包含另一个函数的函数之一。这是posibble吗?如果是这样,请expalain。
#include "head.h"
void fungsiCetak()
{
int i,n;
system("cls");
system("color 1f");
FILE*nip,*nama,*golongan,*anak,*kk,*birth;
nip=fopen("nip.txt","a");
nama=fopen("nama.txt","a");
anak=fopen("jum_anak.txt","a");
kk=fopen("jum_kk.txt","a");
birth=fopen("birth.txt","a");
golongan=fopen("golongan.txt","a");
//////////////////////////////////////////////////////////////////
fflush(stdin);
printf("Berapa data yang ingin di inputkan ? ");
scanf("%d",&n);
i=1;
do{
fflush(stdin);
printf(" Masukan NIP : ");
gets(pegawai.nip);
fprintf(nip,"%s\n",pegawai.nip);
printf("Masukan nama Pegawai : ");
gets(pegawai.nama);
fprintf(nama,"%s\n",pegawai.nama);
printf("Masukan golongan : ");
scanf("%d",&pegawai.gol);
fprintf(golongan,"%d\n",pegawai.gol);
printf("Jumlah anak : ");
scanf("%d",&pegawai.jum_anak);
fprintf(anak,"%d\n",pegawai.jum_anak);
printf("Jumlah anggota keluarga : ");
scanf("%d",&pegawai.jum_kk);
fprintf(kk,"%d\n",pegawai.jum_kk);
printf("Tanggal lahir (dd-mm-yyyy) : ");
scanf("%d-%d-%d",&pegawai.birth.hari,
&pegawai.birth.bulan,
&pegawai.birth.tahun);
fprintf(birth,"%d-%d-%d\n",pegawai.birth.hari,
pegawai.birth.bulan,
pegawai.birth.tahun);
printf("\n");
i++;
} while(i<=n);
fclose(nip);
fclose(nama);
fclose(golongan);
fclose(anak);
fclose(kk);
fclose(birth);
}
void fungsiBaca()
{
system("cls");
int count=0;
int nip2,nip1[20],anak1[20],kk1[20];
int gol[20];
char birth1[30][30];
char bufer[100],buffer1[100];
char nama1[30][30];
struct pegawai;
FILE*nip,*nama,*golongan,*anak,*kk,*birth;
nama=fopen("nama.txt","r");
i=0;
while(fgets(bufer,sizeof bufer,nama)!=NULL)
{
strcpy(nama1[i],bufer);
i++;
}
a=0;
golongan=fopen("golongan.txt","r");
while(a<=i)
{
fscanf(golongan,"%d",&gol[a]);
a++;
}
nip=fopen("nip.txt","r");
a=0;
while(a<i)
{
fscanf(nip,"%d",&nip1[a]);
a++;
}
anak=fopen("jum_anak.txt","r");
a=0;
while(a<i)
{
fscanf(anak,"%d",&anak1[a]);
a++;
}
kk=fopen("jum_kk.txt","r");
a=0;
while(a<i)
{
fscanf(kk,"%d",&kk1[a]);
a++;
}
birth=fopen("birth.txt","r");
a=0;
while(fgets(buffer1,sizeof buffer1,birth)!=NULL)
{
strcpy(birth1[a],buffer1);
a++;
}
search :
fflush(stdin);
printf("----------------------------------------\n");
printf("masukan NIP : ");
scanf("%d",&nip2);
printf("----------------------------------------\n");
for(a=0; a<=i; a++)
{
if(nip1[a]==nip2){
printf("Nama pegawai : %s",nama1[a]);
printf("Golongan : %d\n",gol[a]);
printf("Jumlah anak : %d\n",anak1[a]);
printf("Jumlah KK : %d\n",kk1[a]);
printf("Tanggal Lahir : %s\n",birth1[a]);
count=1;
}
}
if (count==0)
{
printf("Maaf data tidak ditemukan!\n");
}
fflush(stdin);
printf("Ingin mencari data kembali ? [y/n]");
scanf("%c",&kembali);
if (kembali=='y')
{
system("cls");
goto search;
}
fclose(nip);
fclose(nama);
fclose(golongan);
fclose(kk);
fclose(anak);
fclose(birth);
}
void fungsiGaji ()
{
int gol,absen;
float tunj_makan,tunj_anak,tunj_kes,total,gajih_pokok;
fungsiBaca();
//////////////////////////////////////////////////Kondisi gajih pokok
if (gol[a]==1)
{
gajih_pokok=GOl1;
} else if (gol[a]==2)
{
gajih_pokok=GOL2;
} else if (gol[a]==3)
{
gajih_pokok=GOl3;
} else
{
gajih_pokok=GOL4;
}
printf("Gajih pokok : %.2f",gajih_pokok);
/////////////////////////////////////////////// kondisi tunjangan
}
错误消息是 我使用CodeBlocks来创建程序
答案 0 :(得分:1)
问题在于:
int gol,absen; <--- gol is integer
...
if (gol[a]==1) <---- gol[a] ?