I'm trying to debug my program but I keep getting this error from the compiler any ideas? I searched online and I guess I'm using & in the wrong way
Just a side note (I'm only allowed to use <stdio.h> on this program cuz that's what my professors instructions says)
main.c: In function ‘main’:
main.c:18:16: warning: format ‘%c’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[8]’ [-Wformat=]
18 | scanf ("%c", &letters);
| ~^ ~~~~~~~~
| | |
| | char (*)[8]
| char *
main.c:20:28: error: expected expression before ‘]’ token
20 | if (letters == words[][7])
| ^
My program should compare the elements of the first array of characters to each element of the string and if the user typed the word correctly he gets (valid value) if not corrent word he gets (Not valid value.
#include<stdio.h>
int
main ()
{
char letters[] = { "kamneri" };
words[][7] =
{
"anemik", "kameri", "marine", "minare", "makine", "anemi", "mekan",
"krema", "kerim", "inmek", "imkan", "imren", "imran", "erkan",
"ekran", "mera", "krem", "mine", "mira", "name", "ekim", "erik",
"kim", "nem", "nam", "ani", "kin", "kir"};
printf("This is the game\n Your letters are (k,a,n,m,e,r,i)");
for(i = 0 ; i < 7 ; i++)
{scanf("%s", &letters)
if(letters == words[][7])
printf("valid value");
else
print("Not valid value");
}
return 0;
}