Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fussy compiler?

Status
Not open for further replies.

RandallW

Programmer
Jun 24, 2000
18
0
0
US
I can do this:
Code:
   int *a_pointer;

Yet this causes an error during compilation:
Code:
   int *a_pointer = 2369;
It says "error C2440: cannot convert from 'const int' to 'int *' ( new behavior; please see help )"

I checked the error definition from the CD; it has examples
for why the error would show, but not any for my example.

I suppose there's a full manual for the compiler...probably take 2 months to read it.
 
Hi,
If you want an int equal to 2369 then this is the way

int anum = 2369;

if you want a pointer to that int then

int *p_anum;
p_anum = &anum;

What you are doing is trying to point to address 2369.


Pappy
 
Hi again,

I should not have assumed what you wanted.
To get a int pointer to that address this is what you do

int *a_pointer = (int *)2369;

One place this technique is used is writing directly to the video buffer ie.

char __far *scrn = (char __far *) 0xa0000000;

Pappy
PS
__far is a 16bit compiler discriptor.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top