Created
March 13, 2020 09:19
-
-
Save typelogic/d5ae6069e1d226f99af5725bd485242a to your computer and use it in GitHub Desktop.
c++ streams
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <istream> | |
#include <fstream> | |
#include <string> | |
using namespace std; | |
int main() | |
{ | |
string filename = "text.txt"; | |
ios::openmode mode = /* ifstream::in;*/ ios::binary; | |
ifstream fin; | |
fin.open(filename/*, mode*/); | |
/* | |
char c = fin.get(); | |
while (fin.good()) { | |
std::cout << c; | |
c = fin.get(); | |
} | |
*/ | |
char output[100]; | |
if (fin.is_open()) { | |
while (!fin.eof()) { | |
//std::cout << fin; | |
std::cout << fin.readsome << std::endl << std::flush; | |
fin >> output; | |
//std::cout << "*\n"; | |
for(int i=0; i<10; ++i) { | |
std::cout << std::hex << (int)output[i] << std::flush; | |
} | |
std::cout << std::endl << std::flush; | |
} | |
fin.close(); | |
} else { | |
std::cout << "cannot open file\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment