VS2015 error on PPP2 binary IO code

I'm trying to copy some code from the book that demonstrates binary I/O from files, but currently I can't get past the part where I have to open the ifstream with a name string. The compiler keeps flagging the variable name "ifs" as an error and saying this: "incomplete type name not allowed". The code I have right now is this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// binary_io.cpp : Defines the entry point for the console application.
// Osman Zakir
// 2 / 22 / 2017
// Bjarne Stroustrup: Principles and Practice Using C++ 2nd Edition
// Chapter 11 Section 11.3.2
// Binary mode File I/O code listing

#include "cust_std_lib_facilities.h"
#include <iostream>

int main()
{
	using namespace std;
	cout << "Please enter input file name\n";
	string iname;
	cin >> iname;
	ifstream ifs{ iname, ios_base::binary };
}


The check for !ifs also isn't working.

Edit: Never mind. I figured out the problem. I'm not #including <fstream>.
Last edited on
Also #include<string> to make the code portable, it seems your compiler is running the program without it
Topic archived. No new replies allowed.