input file c++

sample data: 757935403 544999979 175906848 538976380
757795452 170601773

i m trying to read this input line what it does it grab first set of integer and convert into character then if this is space it goes to next line and then print the set of integer..so on as so fourth.

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
55
 int main( int argc, char* argv[] )
{
	if ( argc < 2 )
	{
		cerr << "Arguments missing" << endl;
		cerr << "Usage: CharCounter infile" << endl;
		return 1;		// program failed
	}

	// set up input file
	ifstream file;	// declare an input file variable (object)

	file.open( argv[0], ifstream::in ); // open an input file (binary)

	if ( !file.good() )
	{
		// operation 
		cerr << "Cannot open input file " << argv[0] << endl;
		return 2; 		// program failed (input)
	}

	int lNumberOfCharacters = 0;
	int lCharacterCounts[256];

	// init array
	for ( int i = 0; i < 256; i++ )
		lCharacterCounts[i] = 0;

	

	while ( file.good() )
	{
		int lChar = file.get();
// some code


		
	}
// this is a logic where is a is a input !!
int a;
	cout << "what is your code?" << endl;
	cin >> a;
	cout << "You entered: " << a << endl;
	do {
		if (a == ' ') {
			cout << endl;
		}
		int b = a % 256;
		cout << char(b);
		int c = a >> 8;
		a = c;	
	} while (a != 0);
*/

Topic archived. No new replies allowed.