使用结构体输入输出流问题#include <iostream>
#include <fstream>
using namespace std;//定义一个结构体,如:
struct TESTSTRUCT
{
int ID;
char Name[9]; 
char *Text; //由于某些原因此处必须声明为字符串指针
}
TESTSTRUCT test;
ofstream outdata("data.dat",ios::out|ios::binary);
ifstream indata("data.dat",ios::in|ios::binary);由于结构体中使用了字符串指针,如果直接使用
outdata.write((char *)&test,sizeof(struct TESTSTRUCT));

indata.read((char *)&test,sizeof(struct TESTSTRUCT));
写入和读得的最后一项都将是字符串指针的地址这该如何解决?可否给出具体代码!我试过一项一项写入和读出,却在读字符串时,频频出错!