C++中txt文件读取失败

编译无错误,但运行时,文件根本打不开,TXT文件,源代码是在同一文件里面,

不要用绝对路径或相对路径,有时候用路径会打开失败。

代码贴出来看看,路径写对了吗

以下是我写的源代码

void ReadData(SqList &L)
{
int i=0;

InitList(L);

ifstream infile("c:\book.txt");

while(!infile.eof())

{
infile>>L.elem [i].no;

infile>>L.elem [i].name;

infile>>L.elem [i].price ;

i++;

}

L.length =i;

infile.close ();

}

void WriteData(SqList L)
{
int i;

ofstream outfile("c:\book.txt");

for(i=0;i<L.length-1 ;i++) {
outfile<<L.elem [i].no <<" "<<L.elem [i].name <<" "<<L.elem [i].price <<endl;

}

outfile<<L.elem [i].no <<" "<<L.elem [i].name <<" "<<L.elem [i].price;

outfile.close ();

}

void PrintAllBook(SqList L)
{
int i;

ReadData(L);

for(i=0;i<L.length ;i++)
{
cout<<L.elem [i].no <<" "<<L.elem [i].name <<" "<<L.elem [i].price <<endl;

}
}