Reputation: 1949
I am getting a compilation error for the following statement:
void read_text(int & c1, int & c2, string file1, string file2 )
I seem to get error when passing the address; the error message is below:
Error 13 error C2143: syntax error : missing ')' before '&' \\vmware-host\shared folders\school\misc\johncpp\porj\similarity.c 101
I am using on Visual Studio.
Upvotes: 0
Views: 87
Reputation: 225032
No, you can't use C++ style references in C. You'll need to pass pointers to get similar behaviour.
Upvotes: 1
Reputation: 57784
C does allow passing a pointer, which is the usual mechanism for parameter references. However, the syntax is not as used in C++, which you have used. Instead it is:
void read_text(int * c1, int * c2, string file1, string file2)
Upvotes: 3
Reputation: 272657
Your syntax is invalid in C. I'm not sure what your aim is. Either you're thinking of C++ references (which are a C++ thing), or you're thinking of pointers, in which case you want *
, not &
.
Upvotes: 2