When write add without parentheses somewhere in your code, it evaluates to a function pointer.
It is unclear to me what your code is supposed to do, so I can't say how to fix it (adding '()' on line 8 would remove the warning, although your code has problems apart from that..).
You initialise your array add_transaction[] with only one integer, so its size is one; You are thus out of bonds when accessing add_transaction[1]. Also the initialisation of the array is trying to add up a and b, which are never initialized;
Hey there , you have declared your add_transaction[] array to be holding integers and trying to store int& in it
I mean
"add" gives the address of function where from it starts
and even it's integer value it cannot be stored in integer array . You have to do as follows
int (*add_transaction_array)(void)[2] = { add , add } ; // will work fine , or
That's it !!!
Now "add" will yield int& and our array is now capable of storing address of function having signature
int func_name(void) ;
I given an example.I want to be my array's element item 3,4,5,50,638...
@SwapnilGhode And i tried before ur suggested method.But funcs and arrays doesn't work together.
@hamsterman I don't take an error.But doesn't write numbers in screen:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <stdio.h>
#include <stdlib.h>
int a,b;
int add(){
return (a+b);
}
int add_transaction[2];
int main()
{
if(a==5&&b==6){
add_transaction[0]=add();
printf("%d%s",add_transaction[0],"\n");}
if(a==1&&b==2){
add_transaction[1]=add();
printf("%d%s",add_transaction[1],"\n");}
system("PAUSE");
return 0;
}