How can I call a function, given its name as a string?

Answers were Sorted based on User's Feedback



How can I call a function, given its name as a string?..

Answer / alice

You can't. You have to construct a table of two-field
structures, where the first field is the function name as a
string, and the second field is just the function name
(which the compiler will convert to its calling address).
Then search the table to get a string match in the first
field, and use the second field to call the function.

Is This Answer Correct ?    3 Yes 1 No

How can I call a function, given its name as a string?..

Answer / ashay

Ashay here according to the programming scenario u cannot
give a function the name of a system defined identifier and
string is a system defined identifier and as aresult of
which u r unable to call

Is This Answer Correct ?    9 Yes 8 No

How can I call a function, given its name as a string?..

Answer / neeraj

#include<stdio.h>
#define string sum1()
int main(){

int k=string;
printf("%d",k);
getch();
return 0;

}
sum1()
{
int c=6;
int d=7;
return(c+d);
}

Is This Answer Correct ?    0 Yes 1 No

How can I call a function, given its name as a string?..

Answer / hemant ware

A function can be called by object name and a function
name (sring ) with dot(.) operator.
e.g
class hi
{
void string()
{
cout<<"hello I am in string function";
}
};
void main()
{
hi h1;
h1.string();
}

Is This Answer Correct ?    12 Yes 46 No

Post New Answer

More C Interview Questions

Explain how can a program be made to print the line number where an error occurs?

0 Answers  


The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?

0 Answers  


What is the acronym for ansi?

0 Answers  


Why c is known as a mother language?

0 Answers  


1 1 2 1 2 3 1 2 3 4 1 2 3 1 2 1 generate this output using for loop

2 Answers  






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.

0 Answers  


Convert the following expression to postfix and prefix (A+B) * (D-C)

3 Answers   Satyam,


Can we declare variable anywhere in c?

0 Answers  


What is string concatenation in c?

0 Answers  


what is the value of b if a=5; b=++a + ++a

31 Answers   Infosys, TCS, Tech Mahindra,


What are keywords c?

0 Answers  


How can I generate floating-point random numbers?

0 Answers  


Categories