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
Write a program to check armstrong number in c?
What is the use of #define preprocessor in c?
What does void main () mean?
Explain what are multibyte characters?
Why do we use return in c?
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
What is the difference between the expression “++a” and “a++”?
What will be your course of action for a push operation?
How can I change their mode to binary?
How will you divide two numbers in a MACRO?
What are compound statements?
how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software
Explain the use of keyword 'register' with respect to variables.
What is modeling?
Why is struct padding needed?