访问“内存地址”时出现问题 [英] Problem in accessing a 'memory address'

查看:87
本文介绍了访问“内存地址”时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




i需要将值存储到特定的内存位置而不需要

a变量。


那么,如何在不使用变量的情况下访问内存地址?


是否有可能在C ???


Plz,帮帮我..


提前致谢

Sethu



i need to store a value to a particular memory location without having
a variable.

So, how can i access a ''memory address'' without using variables??

Is it possible in C???

Plz, help me..

Thanks in advance
Sethu

推荐答案

se*****@gmail.com 写道:
se*****@gmail.com wrote:

i需要在没有

a变量的情况下将值存储到特定的内存位置。
i need to store a value to a particular memory location without having
a variable.



为什么?


如果您的意思是想要写入机器中的地址

你只有数字形式,那么你就不可能在标准C中表达

;你必须使用实现扩展。

Why?

If you mean that you want to write to an address in your machine that
you only have the numerical form of, then you can''t portably do
that in standard C; you''ll have to use an implementation extension.


那么,如何在不使用变量的情况下访问内存地址?
So, how can i access a ''memory address'' without using variables??



这取决于你所说的变量。 (不,我是认真的。

你算一个像`* p`变量的表达式吗?)

That depends on what you mean by a "variable". (No, I''m being serious.
Do you count an expression like `*p` a variable?)


是吗可能在C ???
Is it possible in C???



无法从你的描述中得知。


-

Chris" .enable校对 Dollin

报价设施包括缺乏原创思想。 /华丽之夜/

Can''t tell from your description.

--
Chris ".enable proofreading" Dollin
"A facility for quotation covers the absence of original thought." /Gaudy Night/


se ***** @ gmail .com 说:

hi,


i需要将值存储到特定的内存位置而不必

a变量。


那么,如何在不使用变量的情况下访问内存地址?


是否有可能在C ???


i need to store a value to a particular memory location without having
a variable.

So, how can i access a ''memory address'' without using variables??

Is it possible in C???



这不是真的问题。问题是:


1)是否可以在所有目标平台上使用?

2)这个值在所有这些平台上都具有相同的语义吗? br />

如果这些问题中的任何一个的答案都是不,那么C就不能帮助你挥动一个

的魔杖来实现它。


如果您使用的是受保护模式的操作系统,如Windows或Unix,

通常是不可能的(除非你是在系统中向下,或者

,除非你使用某种类型的实模式模拟器。


如果你使用的是实模式系统,如MS-DOS或CP / M,它可能是

可能。


至于语义,那不太可能是可移植到您的所有目标

平台,除非它们非常相似或除非您只有一个

目标平台。


鉴于所有那么,你可以在C中做到这一点(但结果不是由

C lan定义的guage - C让你有能力做这样的事情,但是你自己

就这样吧!):


*(unsigned char *)0xB8000000UL = 65;


在适当的系统上,这会在

左上角的屏幕上写下字母A。在一个不太合适的系统上,你的机器很可能会崩溃。警告程序员!


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:正常服务将尽快恢复。请不要

调整您的电子邮件客户端。

That isn''t really the question. The questions are:

1) is it possible on all your target platforms?
2) would this value have the same semantics on all those platforms?

If the answer to either of those questions is "no", C can''t help you wave a
magic wand to make it so.

If you''re using a protected-mode operating system such as Windows or Unix,
it''s generally not possible (unless you''re way down in the system, or
unless you''re using a real-mode emulator of some kind).

If you''re using a real-mode system such as MS-DOS or CP/M, it may be
possible.

As for semantics, that''s unlikely to be portable across all your target
platforms unless they are extremely similar or unless you only have one
target platform.

Given all that, you can do this in C (but the outcome is not defined by the
C language - C gives you the power to do things like this, but on your own
head be it!):

*(unsigned char *)0xB8000000UL = 65;

On an appropriate system, this writes the letter ''A'' on the screen in the
upper left hand corner. On a not-so-appropriate system, it may well crash
your machine. Caveat programmer!

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: normal service will be restored as soon as possible. Please do not
adjust your email clients.


文章< 11 ************** ********@f16g2000cwb.googlegroups .com> ;,

< se ***** @ gmail.comwrote:
In article <11**********************@f16g2000cwb.googlegroups .com>,
<se*****@gmail.comwrote:

>我需要将值存储到特定的内存位置而不需要变量。
>i need to store a value to a particular memory location without having
a variable.



这听起来像是课堂作业。

That sounds like a class assignment.


>那么,我怎样才能访问''内存地址''不使用变量?
>So, how can i access a ''memory address'' without using variables??


> C ???有可能吗?
>Is it possible in C???



我不确定你是否在询问指针,或者你是否要求

如何在某个特定值上存储一个值地址位置没有

要经过很多步骤来创建一个变量,链接器会将
恰好放在所需的位置?

-

编程是在你忙于制定其他计划时发生的事情。

I''m not sure if you are asking about pointers, or if you are asking
how to store a value at a particular address location without having
to go through a lot of steps to create a variable that the linker will
happen to put at the desired location ?
--
Programming is what happens while you''re busy making other plans.


这篇关于访问“内存地址”时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆