【问题标题】:c - cheak readable bytesc - 欺骗可读字节
【发布时间】: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”。

标签: c memory ram readable


【解决方案1】:

如果一个字节不可读,操作系统将向您的进程发送一个信号。您需要捕获该信号,否则您的程序将终止。

阅读课程教科书中的信号。

【讨论】:

    猜你喜欢
    • 2017-04-08
    • 2014-01-18
    • 1970-01-01
    • 1970-01-01
    • 2016-03-07
    • 2011-06-27
    • 1970-01-01
    • 1970-01-01
    • 2015-09-15
    相关资源
    最近更新 更多