C code problem Help

Hello guys,
I can not understand why it doesn't working. I would like some help from you folks.
thank you for your time. I'd appreciate any help given.

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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
/* is it in the word? */
int in_word(char, char*);
int
in_word(char z, char* word) {
        int i = 0;
        while(word[i] != '\0') {
                if(word[i] == z) return 1;
                i++;
        }
        return 0;
}
 
 
/* random number generation */
int RNG(int, int);
int
RNG(int min, int max) {
    srand(time(NULL));
    int res = rand();
    while(res < min || res > max) {
        srand(time(NULL));
        res = rand();
    }
   
    return res;
}
 
 
/* --- */
int show_guessed(char*, char*);
int
show_guessed(char* word, char* correct) {
         char pavles[20];
         int i      = 0;
         int length = 0;
         
         while(word[i] != '\0') {
                 pavles[i] = '-';
                 i++; length++;
         }
         
         pavles[i] = '\0';
         i         = 0;
         while(correct[i] != '\0') {
                 int j = 0;
                 while(word[j] != '\0') {
                         if(word[j] == correct[i])
                                pavles[j] = correct[i];
                         j++;
                 } i++;
         }
         
         printf("Current word : %s\n", pavles );
         i = 0;
         while(pavles[i] != '\0') {
                 if(pavles[i] == '-') return 0;
                 i++;
         }
         return 1;
}
 
 
/* :D */
void show_mistake(int);
void
show_mistake(int mistake) {
        if(mistake == 0) {
                printf("    +-------+\n");
                printf("    |       |\n");
                printf("            |\n");
                printf("            |\n");
                printf("            |\n");
                printf("            |\n");
                printf("    ============\n");
        }
        else if(mistake == 1) {
                printf("    +------+\n");
                printf("    |      |\n");
                printf("    o      |\n");
                printf("           |\n");
                printf("           |\n");
                printf("           |\n");
                printf("   ============\n");
        }
        else if(mistake == 2) {
                printf("    +------+\n");
                printf("    |      |\n");
                printf("    o      |\n");
                printf("    |      |\n");
                printf("           |\n");
                printf("           |\n");
                printf("   ============\n");
        }
        else if(mistake == 3) {
                printf("    +------+\n");
                printf("    |      |\n");
                printf("    o      |\n");
                printf("   /|      |\n");
                printf("           |\n");
                printf("           |\n");
                printf("   ============\n");
        }
        else if(mistake == 4) {
                printf("    +------+\n");
                printf("    |      |\n");
                printf("    o      |\n");
                printf("   /|\\    |\n");
                printf("           |\n");
                printf("           |\n");
                printf("   ============\n");
        }
        else if(mistake == 5) {
                printf("    +------+\n");
                printf("    |      |\n");
                printf("    o      |\n");
                printf("   /|\\    |\n");
                printf("   /       |\n");
                printf("           |\n");
                printf("   ============\n");
        }
        else if(mistake == 6) {
                printf("    +------+\n");
                printf("    |      |\n");
                printf("    o      |\n");
                printf("   /|\\    |\n");
                printf("   / \\    |\n");
                printf("           |\n");
                printf("   ============\n");
        }
        else if(mistake == 7) {
                printf("    +------+\n");
                printf("    |      |\n");
                printf("    o      |\n");
                printf("   /|\\    |\n");
                printf("   / \\    |\n");
                printf("         --|\n");
                printf("   ============\n");
        }
        else if(mistake == 8) {
                printf("    +------+\n");
                printf("    |      |\n");
                printf("    o      |\n");
                printf("   /|\\    |\n");
                printf("   / \\    |\n");
                printf("       ----|\n");
                printf("   ============\n");
        }
        else if(mistake == 9) {
                printf("    +------+\n");
                printf("    |      |\n");
                printf("    o      |\n");
                printf("   /|\\    |\n");
                printf("   / \\    |\n");
                printf("     ------|\n");
                printf("   ============\n");
        }
        else if(mistake == 10) {
                printf("    +------+\n");
                printf("    |      |\n");
                printf("    |  o   |\n");
                printf("   /|\\    |\n");
                printf("   /|\\    |\n");
                printf("    |------|\n");
                printf("   ============\n");
        }
}
 
 
/* main function */
int
main() {
        char correct[100];
        char words[20][10] = { "ACHIVEMENT", "ABDICATION", "ABSOLUTELY", "BLACKJACKS",
                               "MAXIMIZING", "JACKHAMMER", "OBJECTIVES", "MOBILIZING",
                               "HYPNOTIZED", "EMPATHIZED", "EXCELLENCY", "EMPHASIZED",
                               "VAPORIZING", "BANKRUPTCY", "PREJUDICED", "PROJECTING",
                               "FREQUENTLY", "EXPENDABLE", "BLACKBERRY", "ACCOMPLISH" };
 
 
        int correct_i = 0;
        int mistake   = 0;
        int all_      = 0;
        char letter   = '\0';
        char word[10]; strcpy(words[ RNG(0, 19) ], word);
        printf("Welcome. You have only 10 tries.\n");
 
        while(all_ == 0 && mistake < 10) {
                printf("Type a letter: ");
                scanf(" %c", &letter);
               
                if(!  in_word(letter, correct)
                   && in_word(letter, word)
                ) {
                        correct[correct_i] = letter;
                        correct_i++;
                        correct[correct_i] = '\0';
                       
                        all_ = show_guessed(word, correct);
                }
                else { mistake++; show_mistake(mistake); }
        }
        if(mistake == 10) printf("--HANGED: '%s'\n", word );
        else printf("++WIN\n");
 
        return 0;
}
Why not ask the friend who wrote it?
http://www.cplusplus.com/forum/general/153757/
I am the same folk still with the same question. why dont you try and give me some answers?
Ask the friend who wrote it.

Line 7 makes no sense: int
int is used when declaring an integer variable but no variable name, not even a semicolon is given. The whole thing makes no sense when it comes to variables and looks very much copy/pasted.
While I agree about asking the person that wrote the code, there is actually nothing wrong with line 7. It could be written like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int
in_word(char z, char* word) { 
...

// Or
int in_word(char z, char* word) {
...

// Or 

int



in_word(char z, char* word) {
...

In most circumstances C/C++ isn't whitespace sensitive.

Topic archived. No new replies allowed.