473,509 Members | 2,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Assing address to pointer

In the following code:

unsafe class X
{
byte* _address;
void test()
{
_address=(byte*)144220152;
}

}

Why the watch windows shows a differtent address for _address variable
?

Jan 9 '06 #1
10 2863
Vlad,

Are you sure you are not looking at the hexidecimal format for the
number? Does it show you 8989FF8 instead (this is the same value in hex
format)?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vlad" <a.*********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
In the following code:

unsafe class X
{
byte* _address;
void test()
{
_address=(byte*)144220152;
}

}

Why the watch windows shows a differtent address for _address variable
?

Jan 9 '06 #2
Thanks for your help, but the problem isn't hexidecimal format

Jan 9 '06 #3
Vlad,

Well, I changed the _address field and the test method to be public, and
then wrote the value of _address out to the console after I ran test. The
value was the same.

There must be something else changing it which is not shown in the code
that you posted.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Vlad" <a.*********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
In the following code:

unsafe class X
{
byte* _address;
void test()
{
_address=(byte*)144220152;
}

}

Why the watch windows shows a differtent address for _address variable
?

Jan 9 '06 #4

"Vlad" <a.*********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
| In the following code:
|
| unsafe class X
| {
| byte* _address;
| void test()
| {
| _address=(byte*)144220152;
| }
|
| }
|
| Why the watch windows shows a differtent address for _address variable
| ?
|

_address is located on the stack and it's a pointer so the stack location
will hold the value you set by _address=(byte*)144220152;
To find the value of byte* you'll have to look at the contents of this
location.

Willy.
Jan 9 '06 #5
I change the question: What is the largest address that I can assign
to pointer ?

Jan 10 '06 #6
I know, I'm interested at the address of pointer rather the value

Jan 10 '06 #7

"Vlad" <a.*********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
|I know, I'm interested at the address of pointer rather the value
|

What do you mean by that?

_address is a variable located on the stack, you set the contents of this
location to 144220152 by this assignment:

_address=(byte*)144220152; // set _address to 0x08989ff8

So suppose your _address is at 0x00125604; after the assignment, the int
value at 0x00125604 will contain 0x08989ff8.
Note that the value will be DWORD swapped, so the debugger will show
0xf89f9808.

Willy.


Jan 10 '06 #8

"Vlad" <a.*********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
|I change the question: What is the largest address that I can assign
| to pointer ?
|

The largest user address on 32 bit windows is 0x7fffffff (decimal
2147483647), note that while you can point to anything between 0 and
0x7fffffff in your address space, it does not mean that read or write
from/to anything. What exactly are you trying to achieve.

Willy.
Jan 10 '06 #9

Thanks for your patience this is the last post in the thread
It's wrong think that the following code in c# are equivalent?
byte* p;
p=someAddress

----------------------------------------------------
IntPtr p=new IntPtr(someAddress)
The pointers are address container?

Jan 10 '06 #10

"Vlad" <a.*********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
|
| Thanks for your patience this is the last post in the thread
| It's wrong think that the following code in c# are equivalent?
|
|
| byte* p;
| p=someAddress
|
| ----------------------------------------------------
| IntPtr p=new IntPtr(someAddress)
|
|
| The pointers are address container?
|

More or less;
case1: p is a variable that holds a pointer that points to a byte.
case2: p is a variable that holds a pointer to a void type.

Willy.
Jan 10 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
2439
by: johny smith | last post by:
I am trying to figure out a way to print the address of what called a certain function once inside the function. I am assuming that this information is on the stack somewhere. But can someone...
9
3171
by: Cheney Stallman | last post by:
I have a class as following: class X { public: static X* Create() { return new X(); }
35
10740
by: hasho | last post by:
Why is "call by address" faster than "call by value"?
15
2217
by: dandelion | last post by:
Hi, Just another question for the standards jockeys... Suppose I have an Interrupt Vector Table located at address 0x0000 (16-bit machine). I want to dump the context of the IVT, by treating...
7
1585
by: realgeek | last post by:
I am novice to C; or rather I have forgoteen C long ago cause I'm a young programmer and i didn't do much of it. I have int *a; int l; I have some logic that creates an array of arbitrary length...
16
3131
by: jimjim | last post by:
#include <stdio.h> #include <stdlib.h> //WARNING: The function's signature should be: f( int ** ) void f(int *ip) { static int dummy = 5; *ip = &dummy; } int main(){
57
5587
by: Robert Seacord | last post by:
i am trying to print the address of a function without getting a compiler warning (i am compiling with gcc with alot of flags). if i try this: printf("%p", f); i get: warning: format %p...
54
24438
by: John | last post by:
Is the following program print the address of the function? void hello() { printf("hello\n"); } void main() { printf("hello function=%d\n", hello); }
36
3357
by: Julienne Walker | last post by:
Ignoring implementation details and strictly following the C99 standard in terms of semantics, is there anything fundamentally flawed with describing the use of a (non-inline) function as an...
0
7234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7344
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7069
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...
0
7505
tracyyun
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...
0
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
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...
0
4730
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...
0
3203
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
441
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.