got it clear.. thanks guys.

On Tue, Feb 15, 2011 at 1:46 PM, jagannath prasad das
<jpdasi...@gmail.com>wrote:

> here start is pointing to string constant which is created in read-only
> memory which can't be changed.so modifying it in the for loop causes
> segmentation fault
> declare it as a array type
>
>
> On Tue, Feb 15, 2011 at 12:36 PM, rahul <rahulr...@gmail.com> wrote:
>
>> char *start is const char *start, pointer to const char, u can't
>> derefernce it and change it.
>> take a char start[256].try this.
>>
>>
>> On Tue, Feb 15, 2011 at 12:31 PM, dinesh bansal <bansal...@gmail.com>wrote:
>>
>>> Hi All,
>>>
>>> Can you please point me to the error in the following function. It gives
>>> segmentation fault.
>>>
>>> int main()
>>> {
>>>     char *start = "12.12.12.12.12976665176069214";
>>>     char *hex_buf = "65003a0a";
>>>     unsigned short i, j = 0;
>>>     int new_len2 = strlen(hex_buf);
>>>     for (i = 0; ((j+1) < new_len2); i+=2,j+=2)
>>>     {
>>>         start[i] = hex_buf[j];
>>>         start[i+1] = hex_buf[j+1];
>>>     }
>>> }
>>>
>>> Thanks,
>>> --
>>> Dinesh Bansal
>>> The Law of Win says, "Let's not do it your way or my way; let's do it the
>>> best way."
>>>
>>> --
>>> 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.
>>
>
>  --
> 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.
>



-- 
Dinesh Bansal
The Law of Win says, "Let's not do it your way or my way; let's do it the
best way."

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

Reply via email to