Re: [algogeeks] char *arr and char arr[]
you can not change that it will give error if you will try to change if want to modify you should declare it as char a[] = pilani On Sat, Jun 25, 2011 at 12:47 PM, oppilas . jatka.oppimi...@gmail.comwrote: I was reading about how char *arr is different from char arr[]. Now, as in char *arr=Pilani, arr stores the base address of the memory block reserved for Pilani. How, can I change the any character at that particular memory block? arr[0] ='T' gives error. #includeiostream using namespace std; int main(){ char *p=Pilani; // p[0]='K'// does not work. // *(p[0])='s'; //does not work; coutp[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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] char *arr and char arr[]
sol 1 : #includeiostream using namespace std; int main(){ char arr[]=Pilani,*p=arr; p[0]='K';// does not work. *(p[0])='s'; //does not work; coutp[0] (void *)p \n; return 0; } sol 2 : #includeiostream using namespace std; int main(){ char *p=(char *)Pilani; p[0]='K';// does not work. *(p[0])='s'; //does not work; coutp[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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] char *arr and char arr[]
May i know the reason please? On Sat, Jun 25, 2011 at 1:06 PM, hary rathor harry.rat...@gmail.com wrote: sol 1 : #includeiostream using namespace std; int main(){ char arr[]=Pilani,*p=arr; p[0]='K';// does not work. *(p[0])='s'; //does not work; coutp[0] (void *)p \n; return 0; } sol 2 : #includeiostream using namespace std; int main(){ char *p=(char *)Pilani; p[0]='K';// does not work. *(p[0])='s'; //does not work; coutp[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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.