Click here to Skip to main content
15,064,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

using std::fstream;
using std::ifstream;
using std::cout;
using std::cin;
void main()
    char c;
    int i=0;
    ifstream f1("one.mp3");
    cout<<"FILE LENGTH "<<i;
        cout<<"File Not Found";

Thank you
Dinesh Balu
Updated 13-Sep-10 6:44am

Replace the line
Dinesh Balu wrote:
ifstream f1("one.mp3");

ifstream f1("one.mp3", std::ios::in | std::ios:binary);

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.
Richard MacCutchan 13-Sep-10 14:05pm
ios::binary means to read the file without trying to translate end of line characters. ios::in means the file is accessed for input only. Take a look at the MSDN pages for iostream for more information.
Dinesh Balu 13-Sep-10 14:39pm
Thank you Mr.Richard.....
CPallini 13-Sep-10 15:49pm
Thank you Richard. :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900