小编Ale*_*era的帖子

如何将ASCII转换为十六进制值并增加char指针?

int main()
{
    ifstream infile;
    infile >> std::noskipws;
    size_t size = 0;
    infile.open("tworecords.dat", ios::binary);

    if(infile.is_open())
    {
        infile.seekg(0, ios::end);
        size = infile.tellg();
        infile.seekg(0, ios::beg);

        char *buffer = new char [size];
        infile.read(buffer, size);
        infile.close();

        for(int i=0; i <59; i++)
        {
            c1 = (*buffer);
            buffer++;
            cout << c1 << endl;
        }

        std::cout.write (buffer, size);
        cout << endl;
        delete[] buffer;
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我正在读取文件中的数据值,它们以ASCII格式显示.如何制作它以便我可以将值视为十六进制值?

我的第二个问题是如何增加char指针以逐个增加,以便它一次读取一个值,就像我试图在代码中做的那样?

c++ hex pointers

1
推荐指数
1
解决办法
4400
查看次数

标签 统计

c++ ×1

hex ×1

pointers ×1