在C ++中通过ifstream读取文件时出现问题 [英] Problem in reading file through ifstream in C++
本文介绍了在C ++中通过ifstream读取文件时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图读取一个字符长度为78125的文本文件,当我在C ++程序中按如下所示读取并计算字符数时,输出为77500.对于总字符长度大于上述内容的文件,输出不实际...
我正在执行此操作以读取大文件之类的mp3
I was trying to read a text file of which the character length is 78125 and when I read and count character wise in my C++ program as given below the output was 77500. And for files of total character length greater than the above the output was not actual...
I''m doing this to read a mp3 like large file
#include<fstream>
#include<iostream>
using std::fstream;
using std::ifstream;
using std::cout;
using std::cin;
void main()
{
char c;
int i=0;
ifstream f1("one.mp3");
if(f1!=0)
{
while(f1>>c)
{
i++;
}
f1.close();
cout<<"FILE LENGTH "<<i;
}
else
cout<<"File Not Found";
cin>>c;
}
谢谢
Dinesh Balu
Thank you
Dinesh Balu
推荐答案
替换行
Dinesh Balu写道:
Dinesh Balu wrote:
ifstream f1("one.mp3");
ifstream f1("one.mp3");
与
with
ifstream f1("one.mp3", std::ios::in | std::ios:binary);
:)
谢谢,...
可以正常工作99%,但不能在1%的文件中工作.........对于某些文件,它在某些数据之前返回.....
无论如何,谢谢……但是"ios :: binary | ios :: in"模式的含义是什么.
Thank you,...
That''s working 99% but not in 1% files......... for some file it returns previous to some data.....
Any way thanks...... but what''s that "ios::binary|ios::in" mode means.
这篇关于在C ++中通过ifstream读取文件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文