首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

求指点为什么这里的atol没有效果?该如何解决

2012-06-02 
求指点为什么这里的atol没有效果?C/C++ codefstream foutfout.open(testout.dat,ios_base::in|ios_base

求指点为什么这里的atol没有效果?

C/C++ code
    fstream fout;    fout.open("testout.dat",ios_base::in|ios_base::binary);    ofstream fout2;    fout2.open("testout2.dat",ios_base::out|ios_base::binary);    char ex[4];    while(1){        fout.read(ex,5);        if(fout.eof())break;        long l=1;        l=atol(ex);        l=htonl(l);        fout2.write(ex,4);    }    fout.close();    fout2.close();


ex里面是12345678,为什么这里的atol没有效果呢?

[解决办法]
楼主蒙了。atol是把字符串转成整形。所以参数是字符串哦

热点排行