blob: f8af0fbad3031e2a7b5f370f5a19aeef30d40e81 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// This program will take an ASCII text file
// and covert the file to a "character-by-character"
// file which will contain the decimal value from
// each ASCII character.
#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;
int main (int argc, char *argv[])
{
ifstream infile;
ofstream outfile;
char bit;
int charValue;
int i;
//for (i = 0; i < argc; i++)
//cout << i << ": " << argv[i] << endl;
if (argc < 2)
{
cout << "Usage: " << argv[0] << " inputFileName [ outputFileName ]" << endl;
exit(1);
}
cout << argv[0] << ": opening file " << argv[1] << endl;
infile.open (argv[1]);
if ( argc < 3 )
{
outfile.open ("outfile.cbc");
}
else
outfile.open (argv[2]);
i = 0;
while (!infile.eof())
{
charValue = infile.get();
if (infile.good())
outfile << charValue << endl;
i++;
}
infile.close();
outfile.close();
return 0;
}
|