You are here:

C/about memory address

Advertisement


Question
Have  u possible to store a value in to a specifis loation?(for ex i want to store 13 to addre 13456).If yes then how? and give simple example.

Answer
First of all, why do you want to store to a particular location?
How did you get that address and how do you know it is a valid address?

The address program of your program is divided into: data segment, stack segment, heap and text segment.
You cannot write to the text segment. Your program will dump core if you try to.
In the other segments, there can be some variables defined as readonly. So, you are not allowed to write into these.
Other than these, you can write to any part of the address space.

First of all, you will have to find out weather the address you are trying to write is valid one and if you already have some data written in that address, that will get changed by doing this.

So, it is not advisable. But, it is possible.

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Narendra

Expertise

I can answer questions in C related to programming, data structures, pointers and file manipulation. I use Solaris for doing C code and if you have questions related to C programming on Solaris, I will be able to help better.

Experience

6.5

Organizations belong to
Sun Microsystems

Awards and Honors
Brain Bench Certified Expert C programmer.
Advanced System Software Certified

©2012 About.com, a part of The New York Times Company. All rights reserved.