求帮写一个从txt文本中读取数据并输出的函数

//定义试题结构体
typedef struct node
{
int id; //试题编号
char problem[512]; //题干
char optionA[256]; //选项A
char optionB[256]; //选项B
char optionC[256]; //选项C
char optionD[256]; //选项D
char ans[4]; //正确答案
char choose[4];//学员答案
struct node*pNext; //指向下一个试题的指针
}Node;

Node *pHead = NULL; //存放试题的链表的首节点地址
Node *pTail = NULL;

//申请储存空间
void insertNode(int id, char *problem, char *optionA, char *optionB, char *optionC, char *optionD, char *ans)
{
Node *pNew = (Node *)malloc(sizeof(Node));
pNew->id = id;
strcpy(pNew->problem, problem);
strcpy(pNew->optionA, optionA);
strcpy(pNew->optionB, optionB);
strcpy(pNew->optionC, optionC);
strcpy(pNew->optionD, optionD);
strcpy(pNew->ans, ans);
pNew->pNext=NULL;

if (pHead == NULL)
{
pHead = pNew;
pTail = pHead;
}
else
{

//尾插入法
pTail->pNext = pNew;
pTail = pNew;

//头插入法
//pNew->pNext = pHead;
//pHead = pNew;

}
}

准备一个文本文件,放在d盘,里

 面有5行

#include <stdio.h>
#include <iostream>
#include<string>
#include<fstream>
#include<sstream>
using namespace std;


int main()
{
ifstream inf;
inf.open("d:\\test.txt");


string sline;//每一行
string out;
char problem[512]; //题干
char optionA[256]; //选项A
char optionB[256]; //选项B
char optionC[256]; //选项C
char optionD[256]; //选项D


while(getline(inf,sline))
{
istringstream sin(sline);
sin>>problem>>problemA>>problemB>>problemC>>problemD;
cout<<problem<<" "<<problemA<<" "<<problemB<<" "<<problemC<<" "<<problemD<<"\n";

}


}

#include
#include
#include
#include
#include
using namespace std;

int main()
{
ifstream inf;
inf.open("d:\test.txt");

string sline;//每一行
string out;
char problem[512]; //题干
char optionA[256]; //选项A
char optionB[256]; //选项B
char optionC[256]; //选项C
char optionD[256]; //选项D

while(getline(inf,sline))
{
istringstream sin(sline);
sin>>problem>>problemA>>problemB>>problemC>>problemD;
cout<<problem<<" "<<problemA<<" "<<problemB<<" "<<problemC<<" "<<problemD<<"\n";

}

}

 也可以这样写:
ifstream fin(test.txt");

 if( ! fin )
 {
  cerr<<"Can not open datain1 file."<<endl;
  getchar();
  return 1;
 };

 while( ! fin.eof() )
 {
  Datalen++;
  if( Datalen > 99 )
  {
   cerr<<"Too much Data!"<<endl;
   getchar();
   return 1;
  };
  fin>>Data[Datalen];
 };

 fin.close();