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 the maximum length of an identifier?

1158


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

1201


What is a structural principle?

1116


What does sizeof int return?

1036


Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.

1044


What is c language & why it is used?

1064


ATM machine and railway reservation class/object diagram

5214


write a program to concatenation the string using switch case?

2055


Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings

2722


What is a good data structure to use for storing lines of text?

1055


Do you know null pointer?

998


How can I convert a number to a string?

1118


Explain how can type-insensitive macros be created?

966


Did c have any year 2000 problems?

1080


How many types of functions are there in c?

1097