hi,
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 20 2854 se*****@gmail.c om wrote:
i need to store a value to a particular memory location without having
a variable.
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??
That depends on what you mean by a "variable". (No, I'm being serious.
Do you count an expression like `*p` a variable?)
Is it possible in C???
Can't tell from your description.
--
Chris ".enable proofreading" Dollin
"A facility for quotation covers the absence of original thought." /Gaudy Night/ se*****@gmail.c om said:
hi,
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???
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.
In article <11************ **********@f16g 2000cwb.googleg roups.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??
>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.
Walter Roberson wrote:
In article <11************ **********@f16g 2000cwb.googleg roups.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??
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 ?
no, the pointer itself pointing a memory location.
My question is,
char c;
when the compiler reads the above instruction, it will allocates a
memory location dynamically.
but, Is it possible to assign an memory address in the C program
itself?? by the user itself??
Thanks and regards,
Sethu
My question is,
>
char c;
when the compiler reads the above instruction, it will allocates a
memory location dynamically.
>
but, Is it possible to assign an memory address in the C program
itself?? by the user itself??
Thanks and regards,
Sethu
Still not clear.
Did you want to store some variable at Specific-(may be) Hardcoded
memory location. ???
--raxit sheth se*****@gmail.c om wrote:
Walter Roberson wrote:
>In article <11************ **********@f16g 2000cwb.googleg roups.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??
>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 ?
no, the pointer itself pointing a memory location.
Unclear.
My question is,
char c;
when the compiler reads the above instruction, it will allocates a
memory location dynamically.
(Depending what you mean by "dynamicall y" - no; some variables are
allocated addresses statically, before the program is run, in at
least some [1] implementations .)
but, Is it possible to assign an memory address in the C program
itself?? by the user itself??
This is a /different/ (related) question. Fortunately, it has a
simple answer: No.
Standard C provides no way to bind a variable to a specific
memory address.
[1] Probably "most", but my neck isn't stretchy today.
--
Chris ".enable proofreading" Dollin
"I'm still here and I'm holding the answers" - Karnataka, /Love and Affection/ ra************@ yahoo.co.in wrote:
My question is,
char c;
when the compiler reads the above instruction, it will allocates a
memory location dynamically.
but, Is it possible to assign an memory address in the C program
itself?? by the user itself??
Thanks and regards,
Sethu
Still not clear.
Did you want to store some variable at Specific-(may be) Hardcoded
memory location. ???
--raxit sheth
absolutely. yes, i want to store some variable at a Hardcoded
memory location. ???.. is it possible?? ra************@ yahoo.co.in wrote:
My question is,
char c;
when the compiler reads the above instruction, it will allocates a
memory location dynamically.
but, Is it possible to assign an memory address in the C program
itself?? by the user itself??
Thanks and regards,
Sethu
Still not clear.
Did you want to store some variable at Specific-(may be) Hardcoded
memory location. ???
--raxit sheth
absolutely. yes, i want to store some variable at a Hardcoded
memory location. ???.. is it possible in C or C++?? ra************@ yahoo.co.in wrote:
My question is,
char c;
when the compiler reads the above instruction, it will allocates a
memory location dynamically.
but, Is it possible to assign an memory address in the C program
itself?? by the user itself??
Thanks and regards,
Sethu
Still not clear.
Did you want to store some variable at Specific-(may be) Hardcoded
memory location. ???
--raxit sheth
absolutely. yes, i want to store some variable at a Hardcoded
memory location. Is it possible in C or C++?? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: [RaZoR] |
last post by:
hello,
main script creates IE window, put an array there and then calls a child
script. chils script makes an array element equal to some object and
returns control to main script. then main script doesn't see that object
and its functions. why?
here is the code I implemented:
//in main script
|
by: lupher cypher |
last post by:
Hi,
I'm trying to access memory directly at 0xb800 (text screen). I tried this:
char far* screen = (char far*)0xb8000000;
but apparently c++ compiler doesn't know "far" (says "syntax error
before *"). I've tried using __far, _far, FAR, _FAR, and __FAR, all with
the same result. So, then I tried this:
|
by: Anand Subramanian |
last post by:
Hi,
Can someone explain the differences(setup, pre-main()
setup/initialization) between global variables in a C++ and a C program?
The global variables I used are uninitialized.
I have a test.o which declares a global int " int xxx;". Now I link
test.o to a FreeBSD kernel module which then tries to access xxx. If
test.o was compiled from C source the kernel can access the global
variable (which should be of course its own copy in kernel...
|
by: yccheok |
last post by:
Hi, i am from java background and c++ is quite new for me. Consider the
following code:
i obtain an warning from my compiler which states:
a.cpp:45: warning: taking address of temporary
it seems that i am facing problem in accessing an object which has
already been deallocated in stack memory.
unliked java, the object will not be allocated as long as there is a
|
by: debadeepti |
last post by:
Hi All,
I am porting an application from watcom to vc compiler. In watcom and
other compiler (other then vc) memory allocation of __vfptr inside
class object are different. In vc __vfptr is allocated top of the class
object i.e base address of class objects are same as __vfptr address.
But in watcom compiler __vfptr is allocated end of the class object.
Due to this difference, I am getting problem in accessing the member
variable...
| |
by: Martin Jørgensen |
last post by:
Hi,
I'm relatively new with C-programming and even though I've read about
pointers and arrays many times, it's a topic that is a little confusing
to me - at least at this moment:
----
1) What's the difference between these 3 statements:
(i) memcpy(&b, &KoefD, n); // this works somewhere in my code
|
by: Nadav |
last post by:
Hi All,
I am writing a Thread pooled P2P application using C++ and VS2005,
occasionally I get “HEAP: Free Heap block 356bf0 modified at 356f84 after it
was freed“,When the error is triggered, it report a constant memory address,
this address belong to a certain object, if this object is NOT removed from
memory the problem is never produced, however, when the object IS REMOVED the
problem happen while accessing a totally different...
|
by: weidongtom |
last post by:
Hi,
I tried to implement the Universal Machine as described in
http://www.boundvariable.org/task.shtml, and I managed to get one
implemented (After looking at what other's have done.) But when I use
to run a UM program, I kept on getting error messages. I have used
someone else's implementation and it runs fine. I have compared my
code with other's and I still can't figure it out what's wrong with
mine. So please help me out, after 3...
|
by: marvinla |
last post by:
Hello!
I'm a beginner in C, and I'm having trouble with a pointer-to-pointer
reallocation.
This piece of code works well, but Valkyrie warns some parts (pointed
below), and is
breaking my real code.
#include <stdio.h>
#include <stdlib.h>
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |