我正在编写C来读取.bin文件,并将其存储为十六进制无前缀的char字符串。我应该怎么做?我是C语言的新手,在这里呆了几个小时。
Meant to get something like that
#include<iostream>
#include<cstdlib>
#ifndef MYSTACK_H
#define MYSTACK_H
#include<iostream>
#include<new>
using namespace std;
class MyStack
{
private:
int *list;
int top;
int max;
public:
MyStack(int m)
{
int max = m;
list = new int[max];
int top = -1;
}
~MyStack()
{
delete[] list;
}
int push(int);
int pop();
int peek(int &a) const;
};
int MyStack::push(int a)
{
if (top < max - 1)
{
top = top + 1;
list[top] = a;
return 0;
}
return -1;
}
int MyStack::pop()
{
if (top > -1)
{
top = top - 1;
return 0;
}
return -1;
}
int MyStack::peek(int &a) const
{
if (top > -1)
{
return(list[top]);
return 0;
}
return -1;
}
#endif
int main()
{
MyStack m(5);
for (int i = 0; i < 6; i++)
{
int x = 1 + rand() % 100;
cout << x << "\t";
m.push(x);
}
cout << "\n";
for (int i = 0; i < 6; i++)
{
int x;
m.peek(x);
cout << x << "\t";
m.pop();
}
cout << "\n";
system("pause>nul");
}
我可以读取文件并成功打印出十六进制,但是不知道下一步该怎么做。