[迷惑中]!关于fstream与ostream的不解!为什么出现这样的结果!

[疑惑中]!!关于fstream与ostream的不解!!为什么出现这样的结果!!!
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
void main(){
fstream f("a.txt");//使用fstream
f<<"i love you baby";
ifstream a("a.txt");
for(string str;a>>str;)
cout<<str;
cout<<endl;
}
结果:

Press any key to continue
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
void main(){
ofstream f("a.txt");//使用ofstream
f<<"i love you baby";
ifstream a("a.txt");
for(string str;a>>str;)
cout<<str;
cout<<endl;
}
结果:
iloveyoubaby
Press any key to continue

为什么结果不同呢?
请明白人解释一下,小弟菜鸟!
------解决方案--------------------
根据版规,0分帖全部转移至非技术区!
http://topic.csdn.net/u/20080830/18/189fc510-7842-42c1-8029-cf8f3130f4c3.html

引用就可以获得10个可用分。
3. 如果您的帖子非常精彩,被推荐到论坛首页,为此将奖励您可用分88分。
4. 当您的问题得到解答,完成结帖操作,系统将返还给您提问分数的50%可用分。
5. 每成功增加一位好友,成为好友的双方各会得到20分的可用分赠送,得到300可用分后封顶。
6. 您为何要如此执著、坚定、矢志不移、勇往直前、坚持一百年不动摇地发零分帖呢?


------解决方案--------------------
该回复于2009-10-30 09:12:26被版主删除
------解决方案--------------------
竟然一分都没有。。。太扣了吧