I have a function which accepts a pointer to an int. How
can I pass a constant like 5 to it?

Answers were Sorted based on User's Feedback



I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?..

Answer / guest

You will have to declare a temporary variable.

Is This Answer Correct ?    0 Yes 0 No

I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?..

Answer / om prakash mishra

u have to take a temporary variable and pass its adress to
the pointer...like that given below:

// assuming all the conditions are given


int temp=5;
function(&temp);

Is This Answer Correct ?    0 Yes 0 No

I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?..

Answer / jaya prakash

Only Using type modifiers only constant 5 is sent to
function.

[In previous 2 answers address of variable temp (5) is only
send to fn , not a constant 5]

for that fn-call is

function((int*)5);

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More C Interview Questions

atoi, which takes a string and converts it to an integer. write a program that reads lines(using getline), converts each line to an integer using atoi and computes the average of all the numbers read. also compute the standard deviation

0 Answers  


An array name contains base address of the array. Can we change the base address of the array?

4 Answers   NMIMS, Wipro,


what is the first address that gets stored in stack according to a C or C++ compiler???? or what will be the first address that gets stored when we write a C source code????????

2 Answers   Apple,


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.

0 Answers   IBM,


What does 3 mean in texting?

0 Answers  


What is use of null pointer in c?

0 Answers  


can u give me the good and very optimised code for a car racing game?

0 Answers  


Write a program that takes a 5 digit number and calculates 2 power that number and prints it

7 Answers  


What are the 5 types of organizational structures?

0 Answers  


What is pointer to pointer in c language?

0 Answers  


What is malloc return c?

0 Answers  


What is the deal on sprintf_s return value?

0 Answers  


Categories