if instead of passing "hello" directly to function if we passed char array
p then this would not show as an error right? and why is this so? is it due
to the fact tat p array was not possibly allocated in the read only segment
of memory and hence when passed it can be modified by function? so if const
string is passed directly what causes the error?

On Sat, Aug 27, 2011 at 11:28 AM, sagar pareek <[email protected]>wrote:

> @raj
>
> u already mentioned that if we write :-
> char *p="hello";
> p[0]='k'; // gives runtime error
>
>
> so if we are passing arguments as
>
> modify(char a[],char *b)
> {
> .
> .
> }
>
> main()
> {
> .
> .
> modify("hello","hi");
> .
> .
> }
>
>
> then its actually
> char arr[]="hello";
> char *b="hi";
>
> so ofcourse now
> b[0]='a'; // give u runtime error
>
> now u may be confuse about
> arr[0]='a'; //gives runtime error
>
> here i would like to tell you that arr is char pointer not char array....
> you can check by yourself in :-   http://www.ideone.com/EQrjj
>
> On Sat, Aug 27, 2011 at 10:39 PM, raj kumar <[email protected]>wrote:
>
>>
>> "monsters are monsters"
>>
>>
>>
>> ---------- Forwarded message ----------
>> From: raj kumar <[email protected]>
>> Date: Sat, Aug 27, 2011 at 10:30 PM
>> Subject: Re: [algogeeks] Re: String passing
>> To: [email protected]
>>
>>
>> can't understand what are you trying to say
>>
>> source
>>
>>  --
>> 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.
>>
>
>
>
> --
> **Regards
> SAGAR PAREEK
> COMPUTER SCIENCE AND ENGINEERING
> NIT ALLAHABAD
>
>  --
> 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.
>



-- 
 "People often say that motivation doesn't last. Well, neither does bathing
- that's why we recommend it daily."

-- 
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.

Reply via email to