May i know the reason please?
On Sat, Jun 25, 2011 at 1:06 PM, hary rathor <[email protected]> wrote:
> sol 1 :
>
> #include<iostream>
> using namespace std;
> int main(){
> char arr[]="Pilani",*p=arr;
> p[0]='K';// does not work.
> *(&p[0])='s'; //does not work;
> cout<<p[0]<<" "<<(void *)p<<" \n";
> return 0;
> }
>
> sol 2 :
> #include<iostream>
> using namespace std;
> int main(){
> char *p=(char *)"Pilani";
> p[0]='K';// does not work.
> *(&p[0])='s'; //does not work;
> cout<<p[0]<<" "<<(void *)p<<" \n";
> return 0;
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.