invalid conversion from `char*' to `char'

This is a discussion on invalid conversion from `char*' to `char' within the C++ Programming forums, part of the General Programming Boards category; Hello, I am new to C++, I just started yesterday. I am trying to make a fuction where I can ...

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: