0

hi all
I'm trying to read a document char by char
my question is how do I read the spaces as well?
Thank you!

3
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by alexhkleung
0

This code with print all the characters from any file to the console.

#include<iostream>
#include<fstream>
using namespace std;

const char fileName[] = "FILENAME";

int main() {
	ifstream in(fileName, ios::in | ios::binary);
	while (in) {
		cout << (char) in.get();
	}
	system("pause");
	return 0;
}
0

thx william!

is there a way to make 'in' binary after I've reached certain char? I just want to read the file char by char (including spaces) after certain point in the file.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.