Pelles C forum

C language => Beginner questions => Topic started by: Yadav on May 07, 2013, 07:25:25 PM

Title: error #2068: Expected called object to have function type, but found 'int'.
Post by: Yadav on May 07, 2013, 07:25:25 PM
Hello,
         I am a rookie and I have written a simple code to multiply a number raised to the power value. When I compile the program I get the below mentioned error. If I change the function name then the error vanishes. I think the func "power () "  is an inbuilt function hence I cannot use the func "power()". Kindly help me out.

Code: [Select]
#include<stdio.h>

void power(int n, int p, int *r)
{
int i;
*r = 1;
for(i=1;i<=p;i++)
{
*r *= n;
}
}


int main(void)
{

int num,power,result;

printf("Enter the number\n");
scanf("%d",&num);

printf("Enter the power\n");
scanf("%d",&power);

power(num, power, &result);

printf("Result:%d\n",result);

return 0;
}

Building Ex_D.obj.
C:\Users\KHT\Documents\Pelles C Projects\Chp5\Ex_D.c(30): error #2068: Expected called object to have function type, but found 'int'.
*** Error code: 1 ***
Done.
Title: Re: error #2068: Expected called object to have function type, but found 'int'.
Post by: frankie on May 08, 2013, 09:21:30 AM
You're right.
Change name.
Title: Re: error #2068: Expected called object to have function type, but found 'int'.
Post by: Yadav on May 08, 2013, 04:12:03 PM
Thanx for the confirmation. Cheers!! ;D
Title: Re: error #2068: Expected called object to have function type, but found 'int'.
Post by: Bitbeisser on May 09, 2013, 04:14:35 AM
Hello,
         I am a rookie and I have written a simple code to multiply a number raised to the power value. When I compile the program I get the below mentioned error. If I change the function name then the error vanishes. I think the func "power () "  is an inbuilt function hence I cannot use the func "power()". Kindly help me out.

Not quite. It's a naming conflict, alright but not with any build in function but between your function power() and the variable named power!

Ralf