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

Tell me when is a void pointer used?

1102


which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +

1671


I need previous papers of CSC.......plz help out by posting them.......

2245


Why & is used in scanf in c?

1048


What’s the special use of UNIONS?

1105


How does free() know explain how much memory to release?

1011


Can the sizeof operator be used to tell the size of an array passed to a function?

1056


How can I find out the size of a file, prior to reading it in?

1099


What is the difference between formatted&unformatted i/o functions?

1003


int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above

1219


If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above

997


What is a c token and types of c tokens?

1010


Who developed c language?

1038


why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above

1092


How can I call fortran?

990