warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)’

scanf("%s", &me);

should be

scanf("%s", me);

Explanation:

"%s" means that scanf is expecting a pointer to the first element of a char array.

me is an object array and could be evaluated as pointer. That’s why you can use me directly without adding &. Adding & to me will be evaluated to 'char (*)[20]' and your scanf is waiting char *

Code critic:

Using "%s" could cause a buffer overflow if the user input string’s length is bigger than 20, so change it to "%19s":

scanf("%19s", me);

Leave a Comment