Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION.

Answer Posted / shiva

No.
in g++ you will be clearly notified that you can't define a
function inside another function
but gcc somehow allows following

#include <stdio.h>

int func2(int (*f)()){
(*f)();
return 0;
}
int main ()
{
int func1 ()
{
printf ("\n Inside func 1 ");
return 0;
}
printf("someting");
func1 (); //you can access this fuction inside
main(the function in which you declared func1) with the name
func1
func2(func1); // to access this function outside use
fucntion pointer as a argument
return 0;
}

o/p:
something
Inside func 1
Inside func 1

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is different between auto and local static? why should we use local static?

1122


Why is it that not all header files are declared in every C program?

1212


What is the argument of a function in c?

1045


What is %d used for?

1034


the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above

1247


What is an endless loop?

1269


Explain what is the use of a semicolon (;) at the end of every program statement?

1221


What is binary tree in c?

1098


Explain what is a static function?

1104


What are the features of the c language?

1082


Suggesting that there can be 62 seconds in a minute?

1043


Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

1098


How to declare a variable?

1000


Why should I prototype a function?

1181


Explain enumerated types.

1028