取决于文件中数据的存储方式。1 如果文件中存储的方式为二进制形式数据:需要使用fread(C语言风格)或ifsteam的read成员函数(C++风格。)从文件中读取结构体数据到对应的结构体指针上。如struct test{
int a;};struct test t;fread(&t, 1,sizeof(t), fp); 或file.read(&t, sizeof(t));2 如果文件中,是以文本方式存储的可读的结构体数据:需要根据文件中数据的存储格式,通过fscanf(C语言风格)或ifstream的>>成员函数,读取各个值到对应的结构体成员变量中。如 struct test t;...
#include using namespace std;typedef struct hardware{ int num; int amount; int price;}instruction;int main(){ instruction code[100] = {0}; for ( int j...