reading '\n'
How can I read '\n' as a char?
I want to read character by character \n from a file and then to have a single char.
'\n' is character like 'a', 'b', .....
you read it like any other character
Reading it from file:
1 2 3 4 5 6 7 8 9 10 11
|
#include <iostream>
#include <fstream>
using namespace std;
//.......
ifstream fin ("FileName", ios_base::in);
char ch;
//reading file char by char (better is read bigger block into buffer)
while (fin.get() != '\n');
//now we can read char behind '\n'
ch = fin.get();
//.......
|
You probably wanted something else, but i hope it help
Topic archived. No new replies allowed.