Click here to Skip to main content
15,914,413 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Win XP Pin
Ravi Bhavnani27-Dec-01 10:43
professionalRavi Bhavnani27-Dec-01 10:43 
GeneralRe: Win XP Pin
Alvaro Mendez27-Dec-01 11:30
Alvaro Mendez27-Dec-01 11:30 
GeneralBeta 2 Or Release Candidate Pin
vinuk27-Dec-01 6:31
vinuk27-Dec-01 6:31 
GeneralRe: Beta 2 Or Release Candidate Pin
Christian Graus27-Dec-01 14:54
protectorChristian Graus27-Dec-01 14:54 
GeneralBitwise operators, static cast and Position pointers Pin
27-Dec-01 6:26
suss27-Dec-01 6:26 
GeneralRe: Bitwise operators, static cast and Position pointers Pin
Michael Dunn27-Dec-01 7:10
sitebuilderMichael Dunn27-Dec-01 7:10 
GeneralRe: Bitwise operators, static cast and Position pointers Pin
27-Dec-01 7:40
suss27-Dec-01 7:40 
GeneralRe: Bitwise operators, static cast and Position pointers Pin
Tim Smith27-Dec-01 7:46
Tim Smith27-Dec-01 7:46 
You have GOT to learn how to use the debugger.

Here is the output I got prior to the crash:

Line One
p= 3089908
a=0 0
b=47 47
c=37 37
d=0 0
p with or =3089664
p with + =3089664
Press any key to continue

Now, the first thing you should have done it verify that the values of a, b, c, and d are as expected. It turns out that the hexadecimal value of p is 0x2f25f4. Now, how can d be 0 when the low byte of p is f4?

d=p<<24;
d=p>>24; // get first set of 8 bits
printf("d=%d ",d);
letter=(static_cast(d)); /// convert to 8bit char
d=(static_cast(letter)); /// convert back to UINT


If you look at that code, there are only two lines of code prior to the display of the value of d. The first line "d=p<<24" although odd, just shifts the low 8 bits into the high 8 bits. The bits we are after are still there, just in a strange place. The second line "d=p>>24" shifts the high 8 bits down into the low 8 bits. Hmm, well since that will cause us to lose the bits we are interested in, then that line of code must be wrong. I would imagine that you ment to type "d=d>>24".

Once that error is fixed, it would be functional.

Lets clean up the code some.

First, I don't understand why you are so hell bent on casting to and from a charater. There really is little point.

a = p & 0xFF000000;
printf("a=%d",a >> 24);

b = p & 0x00FF0000;
printf("b=%d",b >> 16);

c = p & 0x0000FF00;
printf("c=%d",c >> 8);

d = p & 0x000000FF;
printf("d=%d",d);


That code isolates each byte of the address just fine without all that extra conversion. The right shifts just aren't needed at all.

Tim Smith
Descartes Systems Sciences, Inc.
GeneralRe: Bitwise operators, static cast and Position pointers Pin
27-Dec-01 12:19
suss27-Dec-01 12:19 
GeneralRAS...I don't get him! Pin
BlackSmith27-Dec-01 6:02
BlackSmith27-Dec-01 6:02 
GeneralRe: RAS...I don't get him! Pin
Masaaki Onishi27-Dec-01 7:02
Masaaki Onishi27-Dec-01 7:02 
GeneralRe: RAS...I don't get him! Pin
Joel Lucsy27-Dec-01 8:43
Joel Lucsy27-Dec-01 8:43 
GeneralRe: RAS...I don't get him! Pin
Rickard Andersson2027-Dec-01 8:57
Rickard Andersson2027-Dec-01 8:57 
GeneralIssues opening files Pin
Stew27-Dec-01 5:51
Stew27-Dec-01 5:51 
GeneralRe: Issues opening files Pin
Chris Meech27-Dec-01 9:29
Chris Meech27-Dec-01 9:29 
GeneralRe: Issues opening files Pin
Stew28-Dec-01 4:45
Stew28-Dec-01 4:45 
GeneralTurning on/off caps lock, num lock and scroll lock Pin
Nnamdi Onyeyiri27-Dec-01 5:34
Nnamdi Onyeyiri27-Dec-01 5:34 
GeneralRe: Turning on/off caps lock, num lock and scroll lock Pin
Chris Meech27-Dec-01 9:34
Chris Meech27-Dec-01 9:34 
GeneralRe: Turning on/off caps lock, num lock and scroll lock Pin
567890123430-Dec-01 1:46
567890123430-Dec-01 1:46 
QuestionModems-Connected or Not? Pin
BlackSmith27-Dec-01 1:46
BlackSmith27-Dec-01 1:46 
AnswerRe: Modems-Connected or Not? Pin
Nish Nishant27-Dec-01 1:58
sitebuilderNish Nishant27-Dec-01 1:58 
GeneralFile size in FTP server... Pin
27-Dec-01 1:22
suss27-Dec-01 1:22 
GeneralBeeep! Pin
Rickard Andersson2027-Dec-01 1:19
Rickard Andersson2027-Dec-01 1:19 
GeneralRe: Beeep! Pin
Nish Nishant27-Dec-01 1:23
sitebuilderNish Nishant27-Dec-01 1:23 
GeneralRe: Beeep! Pin
Rickard Andersson2027-Dec-01 1:44
Rickard Andersson2027-Dec-01 1:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.