I have a small program which when compiling throws me the following errors
error #2168: Operands of '+' have incompatible types 'struct agenda' and 'int'.
error #2113: Left operand of '.' has incompatible type 'int'.
error #2088: Lvalue required.
This is the code that I have done
#include <stdio.h>
struct agenda{
int order, cellular;
char name[30], last_name[30], street[30], city[30], mail[50];
}contact[10];
int main(void)
{
struct agenda *ptrcontact;
ptrcontact = &contact[0];
(*ptrcontact+3).order = 3;
printf("\n\n %d", (*ptrcontact).order);
return 0;
}
because it throws these errors and how to fix them?
*ptrcontact? Itscontact[0]. You should try something like:(ptrcontact + 3)->order = 3;