Hi,
In C++, the type of the variable you send to a function must exactly match the type of the variable the function is expecting. You declared your function like this:
Code:
int linesi (char b, int c);
The function is expecting a char type and an int type. You called your function like this:
Code:
char b[256];
int c;
..
...
linesi(b,c);
You are sending your function a char array and an int. A char array is not the same thing as a char type. Here is how you declare both a char array and a char type:
char b[256];
char ch = 'x';
If you sent the variable ch to your function instead of b, you wouldn't get an error. It turns out that for a char array, the brackets and the size are part of the type of the variable. Your variable 'b' is actually of type char[256]. Here is an example:
Code:
#include <iostream>
#include <fstream>
using namespace std;
int linesi (char b[256], int c, char ch);
int main ()
{
char b[256];
int c;
char ch='x';
cout << "Please enter the filename of a .txt file: ";
cin >> b;
cout << "Please enter the line number: ";
cin >> c;
linesi(b, c, ch);
return 0;
}
int linesi (char b[256], int c, char ch)
{
cout<<endl<<"Here is your input:"<<endl;
cout<<b<<endl;
cout<<c<<endl;
cout<<ch<<endl;
return 100;
}