My code, when compiled, returns the error invalid conversion from ‘char*’ to ‘char’
, and identifies the second last line, return char32
as the problem. I've searched internet and this site and haven't found anything that has helped. I've found the error goes away and the code compiles if I replace the problem line with return *char32
, but I'm not entirely sure why this should be the case. I understand that this is pointer notation, but I'm unsure how they apply to this situation. Also, when I do this and attempt to print *char32
to the terminal, nothing happens, indicating that *char32
in empty. I've also verified that there is indeed a line being read in from the file some file
.
Any and all help with this is appreciated.
Update 1: I am attempting to return a full array from parse()
Update 2: I realise I didn't state my goal for this code. I am attempting to read the first line from the some file
, pass it to parse()
and have the first 32 characters indexed into the array char32
, which will then be passed back to main()
. Sorry for the confusion.
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
char parse(string line), char32[32];
int main()
{
string line;
ifstream vgv;
vgv.open("some file");
getline(vgv, line);
cout << char32;
return 0;
}
char parse(string line)
{
int size = line.size();
for (int count1 = 0; count1 < 32; count1 ++)
{
char32[count1] = line[count1];
}
return char32;
}