Reading/Displaying Binary Files

So I have a code that's supposed to read, write, and display a binary file. The writing part of it is good, but I'm really lost on what I need to get the display and read working. Please keep in mind the display has to come from a structure, and the reading must be after line 49. Any guidance would be greatly appreciated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream> 
#include <fstream> 
using namespace std; 
 
struct Video 
{ 
	char *movieTitle;
	unsigned int numberCopies;
	char *videoType;
	
	Video()
	{ 
		movieTitle = "NA"; 
		numberCopies = -1; 
		videoType = "NA"; 
	} 
}; 

void display(Video *v, int size)
{ 
	for(int count = 0; count<size; count++)
		cout<< <<" "<<endl;
} 

int main ()
{
	Video vd[3]; 
	vd[0].movieTitle = "Indiana"; 
	vd[0].numberCopies =2; 
	vd[0].videoType = "Action"; 
 
	vd[2].movieTitle = "Mission"; 
	vd[2].numberCopies =4; 
	vd[2].videoType = "Action"; 
 
	fstream file("example.bin", ios::out|ios::binary); 
 
	if (!file.fail())
	{ 
		cout<<"Writing now!"<<endl; 
		file.write((char *)vd, sizeof(vd)); 
		cout<<"Done"<<endl; 
		
	} 
	else
	{
		cout << "Unable to open file"; 
		file.close();
	}

	cout<<"Now reading!"<<endl;
	file.read ((char *)vd, sizeof(vd));

	display();
	return 0;
}
The writing part of it is not okay.

You don't want to write a pointer to the file. You want to write to the file what is pointed at by the pointer.
Topic archived. No new replies allowed.