need a little help with some code

hello guys, i get some trouble with this code my friend made. he asked me to solve the error but i can't do anything @__@ . when i compile this code , i got a bunch of error .

" In function `int main()': " < with no specified line
" initializer-string for array of chars is too long " at line 81
" expected primary-expression before ',' token " at line 83,88,98,105,111,117,123
" `UrutMahasiswa' undeclared (first use this function) " at line 98

hope somebody could solve this error, thanks before

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAKS 50
#define LERES 1
#define LEPAT 0
typedef int boolean;

struct tenaga_honorer{
       char nama[31];
       char tempat_lahir[11];
       char jenis_kelamin[2];
       double nilai;
       };
              
void Cetak(tenaga_honorer Daftar[], int maks); 
void CetakKarBaris(char c, int jum);
void Uruttenaga_honorer(tenaga_honorer Daftar[], int maks, int kodeUrut);
int CariNamaSeq(tenaga_honorer Daftar[], int maks, char cNama[]);
int CariNamaBin(tenaga_honorer Daftar[], int maks, char cNama[]);
int Caritempat_lahirSeq(tenaga_honorer Daftar[], int maks, char ctempat_lahir[]);
int Caritempat_lahirBin(tenaga_honorer Daftar[], int maks, char ctempat_lahir[]);
int Carijenis_kelaminSeq(tenaga_honorer Daftar[], int maks, char ctempat_lahir[]);
int Carijenis_kelaminBin(tenaga_honorer Daftar[], int maks, char ctempat_lahir[]);

int HitungLulus(tenaga_honorer Daftar[], int maks, double nilaiMin);

int main () {
    int k,nMin;
    char cNama[31];
    char ctempat_lahir[11];
    char cjenis_kelamin[2];
    tenaga_honorer pns[50]=
    {{"TUTI ALAWIYAH","BEKASI","P",70.53},
    {"SUYATMI","BOYOLALI","P",82.52},
    {"UJA SUKMANA","JAKARTA","L",82.82},
    {"THAPA SAYOGA","BEKASI","L",83.92},
    {"TAUFIK","PEMALANG","L",84.92},
    {"MUHAMAD NURDIANSYAH","BEKASI","L",81.92},
    {"TATI NURHAYATI","GUNUNG KIDUL","P",85.92},
    {"TATI HARTATI","WONOSARI","P",86.92},
    {"SURATMI","JAKARTA","P",87.92},
    {"SURYANI","BANTUL","P",88.92},
    {"TATI","JAKARTA","P",89.92},
    {"MUHAJIRIN","BANDUNG","L",80.92},
    {"MONO","PAPUA","L",82.12},
    {"PUTRA","MEDAN","L",82.22},
    {"RANI","PONTIANAK","P",82.32},
    {"RINA","YOGYAKARTA","P",82.42},
    {"SATRIO","JAKARTA","L",82.52},
    {"BUDI","SRAGEN","L",82.72},
    {"MANDA","KLATEN","P",82.82},
    {"NUFI","BANTEN","P",82.91},
    {"LISDA","TANGERANG","P",82.93},
    {"NHILDA","JAKARTA","P",82.94},
    {"AZIZ","PURWOKERTO","L",82.95},
    {"AHMAD","JAKARTA","L",82.96},
    {"RAHMAT","BANDUNG","L",82.97},
    {"MARYATI","BEKASI","P",82.98},
    {"MARYANI","BEKASI","P",82.99},
    {"MAYSAROH","JAKARTA","P",52.92},
    {"ABDUL","PONTIANAK","L",42.92},
    {"GOFUR","JAKARTA","L",62.92},
    {"SITI","BEKASI","P",63.92},
    {"JATI","PONTIANAK","P",64.92},
    {"KUSUMA","WONOSARI","L",65.92},
    {"AKBAR","JAKARTA","L",66.92},
    {"JAYA","PAPUA","L",67.92},
    {"JOKO","BEKASI","L",66.92},
    {"PUSPITA","PONTIANAK","P",69.92},
    {"YADI","JAKARTA","L",60.92},
    {"YOGI","PAPUA","L",51.92},
    {"DANI","WONOSARI","L",53.92},
    {"RAFI","PONTIANAK","L",54.92},
    {"PARIS","JAKARTA","L",56.92},
    {"HALIMAH","PAPUA","P",55.92},
    {"SALI","WONOSARI","L",58.92},
    {"GOZALI","WONOSARI","L",59.92},
    {"PUSPANDARU","BEKASI","L",39.92},
    {"WISNU","JAKARTA","L",41.92}};

    Cetak(tenaga_honorer,50);
    
    printf("\n");
    printf("Nama yang dicari : ");
    gets(cNama);
    CariNamaBin(tenaga_honorer, 50, cNama);
    printf("\n\n");
    
    CetakKarBaris('~',75);
    printf("PENGURUTAN DATA\n");
    CetakKarBaris('~',75);
    printf("1 -> urut berdasar namaMahasiswa\n2 -> urut berdasar noReg\n3 -> urut berdasar nilai\nMasukkan kode pengurutan: ");
    k = getche();
    
    printf("\n");
    UrutMahasiswa(tenaga_honorer,50,k);
    printf("\n");
    Cetak(tenaga_honorer,50);
    
    printf("\n");
    printf("tempat_lahir yang dicari : ");
    gets(ctempat_lahir);
    Caritempat_lahirBin(tenaga_honorer, 50, ctempat_lahir);
    printf("\n");
    
    printf("\n");
    printf("Nama yang dicari : ");
    gets(cNama);
    CariNamaSeq(tenaga_honorer, 27, cNama);
    printf("\n");
    
    printf("\n");
    printf("tempat_lahir yang dicari : ");
    gets(ctempat_lahir);
    Caritempat_lahirSeq(tenaga_honorer, 50, ctempat_lahir);
    printf("\n");
    
    printf("\n");
    printf("Tentukan Nilai minimum : ");
    scanf("%d",&nMin);
    printf("Jumlah tenaga honorer yang melewati nilai minimum : %d ",HitungLulus(tenaga_honorer, 50, nMin));
    printf("\n\n");
    
    system("pause");
    return 0;
}

hi dear friend

but . . . I'm not PRO enough to help you :(

sorry
This code is messed up all over the place.

It pretty much needs a rewrite. A CAREFUL rewrite.
As I have understood you can only write English but you can not read English, can you? If you can also read English then what is the problem? Are you unable to read the phrase "initializer-string for array of chars is too long "? What word in the phrase do you not know?

This string literal "GUNUNG KIDUL" is too long for the array defined as char tempat_lahir[11];
Last edited on
A little hostile today Vlad?
closed account (o3hC5Di1)
Hi there,

As to your actual problems:

" initializer-string for array of chars is too long " at line 81


It means (i think) that lines 35 to 81 are too long to initialise an array.
Try to declare the pns variable and assigning it's values separately.

" expected primary-expression before ',' token " at line 83,88,98,105,111,117,123


You are using the struct name as an argument to these functions:

1
2
Cetak(tenaga_honorer,50); //tenaga_honorer is name of the struct
Cetak(pns, 50); //this is what you mean, but i'm not sure you can pass an array like that to a function 


" `UrutMahasiswa' undeclared (first use this function) " at line 98


1
2
//line 98
UrutMahasiswa(tenaga_honorer,50,k);

This function has not been declared, your other functions were declared in lines 17 to 25, so should this before you use it. You can't use something that doesn't exist, is what the compiler is telling you.

Hope that helps - it may throw some new errors at you though, specifically regarding the passing of an array to a function.

All the best,

NwN
Topic archived. No new replies allowed.