doubt related to string pointers.



what would be the output for the following piece of code ?


if ( "hello" == "hello" )
printf("True\n");
else
printf("False\n");

What is the reason for that ?

-----------------------------------------------------
Secondly, consider the following piece of code.

void main(void)
{
char *str= "hello world";


}
I have seen may C tutorials that say that "str" cannot be
modified. What is the reason for that ? I tried this piece of
code on my machine and I was successfully able to modify it.

.



Relevant Pages

  • Re: How should this sentence be interpreted
    ... procedure will modify it." ... There are immutable classes. ... the passing mechanism is more efficient because of passing only the refence. ... A structure is more complicated to implement correctly, so stick to use classes unless there is a good reason to use a structure. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Two questions for help!
    ... What's the reason for doing this? ... > Making a variable protected ensures that only the class and sub-classes ... > can modify the variable. ... if the derived classes would access them ...
    (comp.lang.cpp)
  • Re: [PATCH] THE LINUX/I386 BOOT PROTOCOL - Breaking the 256 limit (ping)
    ... maybe (some BIOSes leave us ... Or modify the whole code to use 16 bits? ... No reason. ... Dell Linux Solutions linux.dell.com & www.dell.com/linux ...
    (Linux-Kernel)
  • Re: doubt related to string pointers.
    ... >What is the reason for that? ... It is an implementation detail whether there are one or two strings ... is perfectly legal to modify str as often as you want. ...
    (comp.lang.c)
  • Re: summing fields
    ... THe reason I am doing this is ... If you insist on keeping this decidedly un-normal data structure, ... modify your formula/expression to use the Nzfunction to convert nulls to ... another state, you'll have to modify any/all formulas, your table structure, ...
    (microsoft.public.access.forms)