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
Why do we use stdio h and conio h?
What is the difference between procedural and declarative language?
What is #define?
What are the different types of endless loops?
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?
What is the difference between array and pointer?
What is dynamic dispatch in c++?
What are the types of data files?
What are the difference between a free-standing and a hosted environment?
explain how do you use macro?
What is c standard library?
What is the use of ?
How to declare pointer variables?
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
Why is c so popular?