Reputation: 25
this is one function receiving the error but for the life of me I cant figure out why
void serchName(dealers_t *ptr, int numDealers)
{
char dealerName[NAME_LEN];
int index;
printf("please enter the dealer's name:");
scanf("%s", &dealerName);
for (index = 0; index < numDealers; index++, *ptr++)
{
if (strcmp(dealerName, ptr->name) == 0)
{
printf("name: %s\n city: %s\n state:%s\n zip:%i\n phone: %s\n", ptr->name,ptr->city,ptr->state,ptr->zip,ptr->phone);
}
}
}
Upvotes: 1
Views: 837
Reputation: 543
If you pass a char [50] to scanf()
, it will see that as a char * that points to the first element to the array. That's why you don't have to explicitly use the "addressof" (&) operator for a (char) array.
If you use it, you don't get a pointer to the first element of the array, but a pointer to the array itself, and that's why the compiler is giving warning.
Upvotes: 1