Function calling problem

I'm supposed to write a program that prints the bit offset of the first character of a line, followed by 16bits of data in two hex pairs then the ascii characters if printable.

I think I'm doing pretty well but there's an error in my my function dump.cpp or it's call in main.

1
2
3
4
5
//  My header file  //
 
#include <fstream>
#include <iostream>
void dump(char file_name[]);


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//  My main program.  //
#include "proj2.h"
using namespace std;

int main(int argc, char *argv[]){
ifstream file;
unsigned i;

if(argc < 1){
    cout << "No input file given!" << endl;
    return 0;
    }

for (i = 1; i < argc; i++){
    void dump(argv[i]);
    }
}


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
56
57
58
59
60
61
//  The problem file dump.cpp  //
#include "proj2.h"
using namespace std;

void dump(char file_name[]){
unsigned long addr, cnt, cnt2;
unsigned char offset[20];
ifstream file;
unsigned n;

file.open(file_name);
    if(! file){
    cout << "File couldn't be opened!" << endl;
    return;
    }

addr = 0;

while(1){
    file.read((char*) offset, 16);

    cnt = file.gcount();

    if(cnt <= 0) break;

    cout << ( int ) addr << ": ";
    addr = addr + 16;
    cnt2 = 0;

    for ( n = 0; n < 16; n++ ){
        cnt2 = cnt2 + 1;
        if ( cnt2 <= cnt )
            cout << hex << ( int ) offset[n];
        else
            cout << "  ";
        cout << " ";
    }
cout << ' ';


    cout << " ";
    cnt2 = 0;
    for ( n = 0; n < 16; n++ ){
        cnt2 = cnt2 + 1;
        if ( cnt2 <= cnt ){
            if ( offset[n] < 32 || 126 < offset[n] )
                cout << '.';
                else
                cout << offset[n];
        }
    }

    cout << "\n";
    cout << dec;
    if ( file.eof ( ) ) break;
}

file.close();

return;
}


1
2
3
4
5
6
//  My error  //
g++ -c proj2.cpp
proj2.cpp: In function `int main(int, char**)':
proj2.cpp:14: error: variable or field `dump' declared void
proj2.cpp:14: error: invalid conversion from `char*' to `int'
*** Error code 1


Remove 'void' from the function call
Wow... I can't believe that. Thanks
Topic archived. No new replies allowed.