NO

Author Topic: error #2068: Expected called object to have function type, but found 'int'.  (Read 5797 times)

Yadav

  • Guest
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.
« Last Edit: May 09, 2013, 04:07:23 AM by Bitbeisser »

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
You're right.
Change name.
« Last Edit: May 08, 2013, 06:20:05 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Yadav

  • Guest
Thanx for the confirmation. Cheers!! ;D

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
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