what would be the output of the following program?
main()
{
int k = 123;
char *ptr;
ptr = &k;
printf("%d",*ptr);
}
Answer Posted / vadivelt
Hi Srsabariselvan,
If you are not very clear on the answer, please avoid to post
it. Because your answer seems to be misguiding the persons
who are very new to this question(probly pointers).
Who said that a pointer has to hold the address of same
datatype????.... a pointer of any datatype can hold the
address of any other data types(only it is enough to have
proper typecasting).
There will not be a compilation error. But most of the time
loss of data may be there(ie., when a bigger size of
datatype is typecasted to smaller eg: int* is typecasted to
char*). Please read the answer #1 for clear understanding.
Still if you are not clear on the concept, Copy the code
and execute it in ur compiler and analys the output.
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
Hai what is the different types of versions and their differences
What are the 3 types of structures?
Why can't I perform arithmetic on a void* pointer?
Explain how can you determine the size of an allocated portion of memory?
What is the mean of function?
code for quick sort?
How can I direct output to the printer?
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.
What is || operator and how does it function in a program?
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
How do you search data in a data file using random access method?
What is the use of parallelize in spark?
What are the valid places to have keyword “break”?
what is the different bitween abap and abap-hr?
Differentiate between functions getch() and getche().