labs-edaf30/lab1/file_io_example.cc
Sven Gestegard Robertz e4df45f4a9 imported lab skeletons
2021-10-27 15:39:22 +02:00

25 lines
486 B
C++

#include"coding.h"
#include<iostream>
#include <iomanip>
#include<fstream>
void print_bytes(std::string infile)
{
std::ifstream in{infile};
int c;
while((c = in.get()) != EOF ) {
std::cout << "read: " << std::setw(3) << c << " [" << char(c) << "]" << std::endl;
}
}
int main(int argc, char* argv[])
{
if(argc != 2) {
std::cout << "Usage: " << argv[0] << " filename" << std::endl;
return 1;
}
print_bytes(argv[1]);
return 0;
}