0
Hi, I’m getting this error when I try to save a character from a txt. error: request for Member ĩc_str' in’d[j]', which is of non-class type ĩchar'113 | fscanf(iFile, "%c", d[j]. c_str());
Below is the code snippet:
int image::paleta(string nome, int height, int width){
int i, j;
int red,green,blue;
char d[3];
cout << "Arquivo de entrada "<< nome <<endl;
ifstream iFile(nome.c_str());
iFile.ignore(INT_MAX, '\n');
cout << width << " " << height << endl << maxcolor << endl;
for(j = 0; j<height; j++)
{
for (i = 0; i < width; i++)
{
fscanf(iFile, "%c", d[j].c_str());
if(d[0] == '.'){
iFile >> red;
iFile >> green;
iFile >> blue;
set(i,j,red,green,blue);
cout << getred(i,j) << " " << getgreen(i,j) << " " << getblue(i,j) << " ";
}
Here
fscanf(iFile, "%c", d[j].c_str());
you made a certain C/C mix++.char d[3];
is an array of characters and not astring
C++. Use onlyd[j]
, supposing thatheight
< 3.– anonimo
I don’t know if I understand, I don’t use char d[3]? but I need to save characters "." x" or "o"
– schons