?? a755dump.cpp
字號:
// nuovi elementi: fill(), isgraph()
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
/* dump esadecimale e ASCII di un file */
int main(int argc, char * argv[]) {
if (argc == 1){ // termina se non ci sono argumenti
cerr << "Uso: " << argv[0] << " <nomefile>\n";
exit(1);
}
char b;
unsigned short a;
int c=0, r=0;
unsigned int ind=0;
char riga[17] = " "; // 16 spazi
ifstream fin(argv[1]);
if (!fin) {
cerr << "Non sono riuscito ad aprire il file " << argv[1] << "\n";
exit(2);
}
cout.fill('0');
cout << " " << hex << setw(4) << ind << " ";
while (fin.get(b)) {
a=b+128;
ind++;
cout << " " << setw(2) << a;
riga[c] = isgraph(b) ? b : ' ';
if (++c==8) cout << " ";
else if (c==16) {
cout << " " << riga << endl;
c=0;
if (++r==16) {
cin.get();
cout << endl;
r=0;
}
if (fin.peek() != EOF)
cout << " " << setw(4) << ind << " ";
}
}
fin.close();
if (c<16) {
for (r=c; r < 16; r++) {
cout << " ";
riga[r] = ' ';
}
if (c<8) cout << " ";
cout << " " << riga << endl;
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -