Is there anyone could help me to check where I did wrong? Or explain why? I am a beginner and I tried my best to open the binary file. But it just runs out "file is open" "0". Nothing came out.
The objective: The Count3s program opens a binary file containing 32-bit integers (ints). Your program will count the number of occurrences of the value 3 in this file of numbers. Your objective is to learn about opening and accessing files and apply your knowledge of control structures. The name of the file containing data used by the program is "threesData.bin".
my code as below, please help me if you know it. Thank you in advance!
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int count=0 ;
ifstream myfile;
myfile.open( "threesData.bin", ios::in | ios :: binary | ios::ate);
if (myfile)
{
cout << "file is open " << endl;
cout << count << endl; }
else
cout << "cannot open it" << endl;
return 0;
}