ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am not quite sure I understand what you are asking for. A pointer IS a memory address. But if you meant how can you point to a word address then I think you would need to do a int * ptr, since an int is 4 bytes, on the other hand a char is only 1 byte..... I am not sure if this even relevant to what you were looking for ...
Maybe I do not let you understand clearly what I mean.
now, I retell the question below:
it does not matter the pointer's type is "int","char" or other types.
for example:
/*** define an array ***/
int str[10];
after that, we only know there is an array in the memory,
its name is "str",
but, we don't know clearly what its memory address is.
we can only access it by using symbol "str".
we know that,in memory the unit is arranged like this:
segmentffset (eg: 8000:0000);
what I want to do is:
assign the memory address, in the form of "segmentffset",
to a pointer directly.
maybe like this: pointer = 8000:0000;
my English is weak.
maybe I still don't tell you clearly what I mean!
I am sorry!
in old computers, you could access directly from processes memory regions assigned to devices, like video; screen colors, resolution, or sound, etc. (that was the case for my old atari 800 xl) In the actual paradigm on modern layered device management (also linux) when you run your program, the kernel assigns it a memory region only for that process. this region is called in the literature as heap . In this paradigm, the kernel takes care of handling direclty devide memory through API calls , of course, pointer are memory regions, but just mapped onto the heap.
The OS is in charge of actually assigning physical address. You can look to see what address is being assinged to your array by doing &str or something similar. But even that in reality it is a virtual address; now if you actually know the entire computer architecture of your system -- i.e what is the page size, the cache size (including cache associativity and similar other factors) then you can actually do a conversion. Also, where the data segment or text segment begins is completely up to the OS. I am not sure why you are trying to do this -- this is one sure way that your program is not compatible even within similar architectures.
I beg to differ when you say an int* or char* doesn't make any difference while creating an array. IT DOES, b/c when you do str++, in int* you will be jumping 4 bytes, in char* you will be jumping 1 byte.
If you want to handle video to, say , draw things on screens, you have to learn to use a API library like Svgalib, or, for making 3D graphics, openGL its great. Remember that for handling a device, there a thousands of APIs that can do this, the one you should use depends on your system (linux) and taste. you can search them in google
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.