| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 540 人关注过本帖
标题:ifstream问题
取消只看楼主 加入收藏
shanyuxiyun
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-5-14
收藏
 问题点数:0 回复次数:0 
ifstream问题
#include<iostream>
#include<fstream>
#include<cassert>
#include<cstdlib>
using namespace std ;

int main()
{
    ofstream out ;
    out.open("D:\\data.dat",ios_base::out);
    assert(out);
   
    int i ;
    const int size = 10 ;
    int data ;
    for(i = 0 ; i<size ;i++)
    {
          data = rand() ;
          out<<data<<"\t";
    }
    out<<endl;
    out.close() ;
   
    ifstream in("D:\\data.dat");
    assert(in);
    int cnt = 0 ;
    while(!in.eof())
    {
    in>>data ;
    cnt ++ ;
    }
    cout<<"cnt="<<cnt<<endl;
    system("pause");
    return 0 ;
   
    }
为什么cnt是11?
而不是10!
搜索更多相关主题的帖子: ifstream 
2010-05-15 20:16
快速回复:ifstream问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022306 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved