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++)
		{
			info[i].qt1=info[j].sal_amount+info[i].qt1;
		}
		printf("%f", info[i].qt1);
		
	}

	
			
}

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

You need to post that structure

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;

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).

Also where is value for the variable emp on line 7 coming from ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.