@anika : I just found out that it can be done as

int *p = (int *)0x0ff ;
*p=4;

then 4 gets stored in 0x0ff location .
Guys can it be done . Is it Legal ??

On Thu, Jul 28, 2011 at 9:11 AM, Anika Jain <[email protected]> wrote:

> segmentation fault comes when we try to modify or do illegal access to the
> memory that has not been allocated to us..
> the trial to make your variable be at some location of your wish can be
> done only by int *p=4000; *p=10;  but it is illegal coz 4000 memory address
> is not alloted yet for your program.
>
>
> On Wed, Jul 27, 2011 at 11:26 PM, Puneet Gautam 
> <[email protected]>wrote:
>
>> @Anika : pls elaborate the segmentatin part...!
>>
>>
>> On 7/27/11, Anika Jain <[email protected]> wrote:
>> > no we cant..
>> > coz when we do say int *p=4000;
>> > its fine till now.. and if we do *p=10; it is segmentation fault..
>> >
>> > On Wed, Jul 27, 2011 at 10:35 PM, rShetty <[email protected]> wrote:
>> >
>> >> Usually when I declare a variable it will be stored in memory location
>> >> with some address .
>> >> Such as  consider I declare int x=10 , it will stored in some address
>> >> 1003 (say).
>> >> Now my question is can I control the address being assigned to a
>> >> variable in C . Say, I want to store x in address in 4000 and not in
>> >> 1003 defined by the compiler .(Usually this can be done in assembly).
>> >> Can I do that ? Correct me If i am wrong
>> >>
>> >> --
>> >> 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.
>> >
>> >
>>
>> --
>> 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.
>



-- 
Regards
Rajeev N B <http://www.opensourcemania.co.cc>

"*Winners Don't do Different things , they do things Differently"*

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