【发布时间】:2013-07-22 09:29:42
【问题描述】:
需要你们的帮助
我只是想检查字节是否可读,我搜索了 sulution 但没有找到
希望你能帮助我
如果字节可读,我需要这个代码
#include <windows.h>
#include <iostream>
#include <cstdlib>
#include <stdio.h>
void main()
{
float ramsize;
char *ch;
unsigned int j=128,readbyte;
long i;
MEMORYSTATUSEX statex;
statex.dwLength = sizeof (statex);
GlobalMemoryStatusEx (&statex);
ramsize = statex.ullTotalPhys;
for(i=0;i<ramsize;i = i+1)
{
ch = (char*) i;
readbyte = *ch;
// if readbyte is readable
printf("you have readable byte in address: %x , that contain in Binary:",&readbyte);
for(i=0;i<8;i++)
{
if(readbyte&j)
printf("1");
else
printf("0");
j=j>>1;
}
putchar('\n');
// if readbyte is not readable
printf("Sorry: you cant read this byte: %x",&readbyte);
}
}
【问题讨论】:
-
第一,你为什么不接受
unsigned chat j = 128;?这是错误.. -
对不起,我占用了 2 个字节,我忘记更改了
-
但这不是我的问题,它只是一个小错误
-
为什么要检查地址?回答这个问题,可能有助于我们为您提供更好/不同的方法来解决您的根本问题。
-
请更正“cheak”->“check”。