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
Explain can you assign a different address to an array tag?
what are the 10 different models of writing an addition program in C language?
What is define directive?
What is clrscr ()?
How are structure passing and returning implemented?
Is c procedural or functional?
Why main is used in c?
What does typedef struct mean?
What are all different types of pointers in c?
Can we access the array using a pointer in c language?
What is #define in c?
What is c token?
What is preprocessor with example?
Is main is a keyword in c?
What is main () in c?