Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@sarveshgupta-txtmu5 • Dec 6, 2009
Can you please tell that don't we specify char with ' ' rather than " "
is it because we have taken it as a char pointer
seeing as if it can be said that the output will be 6
Is it the right answer? -
@gauravbhorkar-Pf9kZD • Dec 6, 2009
Can you please tell that don't we specify char with ' ' rather than " "
The variable s is a pointer to a string. (its because of "").
is it because we have taken it as a char pointer
seeing as if it can be said that the output will be 6
Is it the right answer?
The answer may be 4 as any pointer is 4 bytes long (correct me if I'm wrong). -
@dipen30-hGOPpa • Dec 6, 2009
compile this code and run it.
It gives the output 2.
can anyone explain how the output is 2? char contain 1 byte. -
@rengaraj-89Rrct • Dec 6, 2009
Sir,sarveshguptaCan you please tell that don't we specify char with ' ' rather than " "
is it because we have taken it as a char pointer
seeing as if it can be said that the output will be 6
Is it the right answer?
How you say the output is 6 ? can you please explain.
R.Rengaraj -
@gauravbhorkar-Pf9kZD • Dec 7, 2009
The output depends on the compiler you use. 16 bit compilers store the pointers as 2 byte entity.dipen30compile this code and run it.
It gives the output 2.
can anyone explain how the output is 2? char contain 1 byte.
Which compiler you used? -
@sarveshgupta-txtmu5 • Dec 7, 2009
Actually i counted the characters in the stringrengarajSir,
How you say the output is 6 ? can you please explain.
R.Rengaraj
As we are calculating the length of the string so i counted the length of the string
but if we see for a normal char we know that in java char occupies 2 bytes
so if it has to consider char the output should be 2
Am I right? -
@dipen30-hGOPpa • Dec 7, 2009
I am using 16-bit compiler. so it gives output 2? -
@saandeep-sreerambatla-hWHU1M • Dec 7, 2009
dipen30I am using 16-bit compiler. so it gives output 2?
Yes the pointer is 2 bytes irrespective of the type it is pointing to.
Depends on the compiler though.
Yes Gaurav said 16 bit gives 2 bytes.
32 bit gives 4 bytes. -
@gauravbhorkar-Pf9kZD • Dec 7, 2009
E_S is exactly right. A pointer is 2 bytes long in 16-bit compilers, and 4 bytes long in 32-bit compilers.dipen30I am using 16-bit compiler. so it gives output 2?
@sarveshgupta: Remember, it is not a character string, its a pointer to a character string. -
@sarveshgupta-txtmu5 • Dec 7, 2009
Ok gaurav.. thanks -
@dipen30-hGOPpa • Dec 8, 2009
thanx gaurav & E-S -
@rengaraj-89Rrct • Dec 8, 2009
-
@aishwarya-hnVUq3 • Jul 10, 2016
answer is 2dipen30compile this code and run it.
It gives the output 2.
can anyone explain how the output is 2? char contain 1 byte.
because char data type 1 byte for * and another byte for s(address of array)