Reputation: 368
I'm writing a program to generate a string of random uppercase letters, then take user input of uppercase letters, along with a character form the user. For any instance of the user input letter in the random string, it replaces that letter with the character entered by the user.
For example, s1 = {BDHFKYL} s2 = {YEIGH} c = '*'
Output = BD*FK*L
Anyway, I'm getting a conflicting types error at the function declaration under main and I implicit decoration at the function call. Does anyone know why? Thank you in advance.
#include <stdio.h>
#include <stdlib.h>
void fillS1(char x[42]);
void fillS2(char x[22]);
void strfilter(char a[], char b[], char c);
int main(int argc, const char * argv[])
{
char s1[42];
char s2[22];
fillS1(s1);
//printf("%s\n", s1);
puts(s1);
fillS2(s2);
strFilter(s1, s2, '*'); //Implicit declaration here
return 0;
}
void fillS1(char x[])
{
for (int i = 0; i < 40; i++)
x[i] = 'A' + random() % 26;
x[40] = (char)0;
}
void fillS2(char x[]){
int i = 0;
printf("Please enter at least 2 capital letters and a maximum of 20.\n");
while (( x[i] = getchar()) != '\n' ) {
i++;
}
x[i] = '\0';
if (i < 3) {
printf("You need at least two letters");
}
else if (i > 21){
printf("You cannot have more than twenty letters");
}
/*else if (((i > 'a')) || ((i < 'z'))){
printf("You many only have capital letters");
} */
else puts(x);
}
void strFilter(char a[], char b[], char c){ //Conflicting types error here
int i = 0;
int n = 0;
while (n < 21) {
for (i = 0; i < 41; i++) {
if (a[i] == b[n]){
c = a[i];
}
}
i = 0;
n++;
}
puts(a);
}
Upvotes: 0
Views: 261
Reputation: 183290
You have a mismatch in your identifiers: strFilter
(with a capital F
) is not the same as strfilter
(with a lowercase f
). So, change your predeclaration from this:
void strfilter(char a[], char b[], char c);
to this:
void strFilter(char a[], char b[], char c);
Upvotes: 4