c - 修改可读字节

标签 c memory ram readable

需要你们的帮助

我只是想检查该字节是否可读,我已经搜索了解决方案但没有找到

希望你能帮助我

我有这个代码,如果字节可读的话,我需要标记该代码

#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);
   }
}

最佳答案

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

阅读课本中的信号。

关于c - 修改可读字节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17784049/

相关文章:

c - Scanf 似乎工作不正常,或者我做错了什么

c++ - C++中进程间通信的最佳方式

c - 疯狂: not understood

c - C中位域的内存管理

assembly - 线性、物理、逻辑和虚拟内存地址有什么区别?

c# - 如何获取任务管理器中显示的应用程序内存使用情况?

c - 如何在C中一一获取字符串的输入

C SDL2-是否有可能消除一些抽象层?

C 中用于 SSHD 的自定义 PAM

c - 最低 504Kb 内存使用量