does anyone know whats wrong with my function?

void quarter(detailstype info[])
	int i,j;
	for(i=1; i<4; i++)
		printf("for month: %d", info[i].month);
		for(j=1; j<emp; j++)
		printf("%f", info[i].qt1);


it is giving me this error: error C2111: pointer addition requires integral operand

Edited by __avd: Removed [Tex] tag

7 Years
Discussion Span
Last Post by abhimanipal
typedef struct{
	char first_name[20];
	char last_name[20];
	int emp_id;
	float qt1[3];
	float qt2[3];
         float qt3[3];
         float qt4[3];
	int month;
	float sal_amount;
	float total;
} detailstype;

Edited by darkdai: n/a


Line 9
info.qt1 is an array, you can't perform assignment or most mathematical operations on an array. The expression info.qt1 returns a pointer to the first element of the array and the code tries to add that to info[j].sal_amount which is a float and so this is an illegal operation.

The following mathematical operations on a pointer are possible.
Addition of an integer
Subtraction of an integer
Difference (subtract of) between 2 pointers

P.S. Line 4 creates indexes from 1 to 3 inclusive. However in C arrays are indexed from 0 (however that may be intentional).

Edited by Banfa: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.