Hi all,
For those of you that don't know me, click on the link if you're interested:
http://www.cplusplus.com/forum/general/38389/ .
Basically, today I'm trying to read from a binary file that contains an array of all the file names that need to be loaded.
Here's my code:
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
|
#include <iostream>
#include <Windows.h>
#include <fstream>
#include <string>
#include <vector>
#include "globals.h"
#pragma comment(lib, "user32.lib")
// Primitive Functions
...
void ReadBinaryFile(std::ifstream input, std::vector<char> files);
std::string fileName = "\\data\\allfiles.bin";
std::ifstream fileInput(fileName, std::ios::binary);
if (!fileInput)
{
return 5; // The check files exist file is missing, so the game won't know what to load (hence the startup must fail).
}
else
{
std::vector<char> files;
ReadBinaryFile(fileInput, files);
for (int i = 0; files[i] != '\0'; i++)
{
// Open all relevant files
}
}
|
Here is ReadBinaryFile:
1 2 3 4 5 6 7 8
|
#include <iostream>
#include <fstream>
#include <vector>
void ReadBinaryFile(std::ifstream input, std::vector<char> files)
{
input.read((char*)&files, sizeof files);
}
|
When I try to compile, I get the following error:
Error 1 error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>' c:\program files (x86)\microsoft visual studio 10.0\vc\include\fstream 890 1
If I get rid of my primitive function, I don't get this error, but obviously the program still won't compile. I need to have this function, as I'll be reading from an unknown amount of files (could be in the tens or the hundreds, depending on the player's preferences).
Also, as a side note, is DWORD a reserved data type in MS VC++ 2010? I got an error for the first time today saying: Error 1 error C2371: 'DWORD' : redefinition; different basic types c:\users\christopher\documents\visual studio 2010\projects\hangmanedu\hangmanedu\datatypes.h 13 1
for my
typedef unsigned int DWORD;
Never before has this happened.