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!

Recommended Answers

All 4 Replies

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;
}

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.

post code. If its reading character by character then it will pick up spaces too.

char c;
while( infile.get(c) )
{

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.