Verán cree un sistema de upload que codifica la imagen en base64 para enviarla por email, y el base64 de la imagen la devuelvo con un char y la estructura de email lo tengo con otro char diferente y el problema es que al intentar concatenar los dos diferentes chars me da error de código.
Un ejemplo del código que tengo es este:
#define FILENAME "..."
static const int CHARS = 76;
static const int ADD_SIZE = 7;
static const int SEND_BUF_SIZE = 54;
static char (*fileBuf)[CHARS];
bool LARGEFILE = true;
size_t read_file()
{
FILE *hFile = NULL;
size_t fileSize(0), len(0), buffer_size(0);
char key = ' ';
hFile = fopen(FILENAME, "rb");
if (!hFile)
{
cout << "Archivo no encontrado!!" << endl;
_getch();
exit(EXIT_FAILURE);
}
fseek(hFile, 0, SEEK_END);
fileSize = ftell(hFile);
fseek(hFile, 0, SEEK_SET);
if (fileSize > 256000)
{
cout << "Espere...\n"
<< endl;
cout << "Para cancelar preciones 'X'\n"
<< endl;
cout << "Para continuar preciones ENTER\n"
<< endl;
key = _getch();
if (tolower(key) == 'x')
exit(EXIT_SUCCESS);
LARGEFILE = true;
}
cout << "Codificando " FILENAME " espere..." << endl;
int no_of_rows = fileSize / SEND_BUF_SIZE + 1;
int charsize = (no_of_rows * 72) + (no_of_rows * 2);
unsigned char *b64encode = new unsigned char[charsize];
*b64encode = 0;
base64_encode(hFile, b64encode, no_of_rows);
string encoded_buf = (char *)b64encode;
if (LARGEFILE == true)
cout << "" << endl;
fileBuf = new char[ADD_SIZE + no_of_rows][CHARS];
buffer_size += strlen(fileBuf[len - 1]);
int pos = 0;
string sub_encoded_buf;
for (int i = 0; i <= no_of_rows - 1; i++)
{
sub_encoded_buf = encoded_buf.substr(pos * 72, 72);
sub_encoded_buf += "\r\n";
strcpy(fileBuf[len++], sub_encoded_buf.c_str());
buffer_size += sub_encoded_buf.size();
pos++;
}
delete[] b64encode;
return buffer_size;
}
const char *headers[] = {
"Date: ...\r\n",
"To: ...\r\n",
"From: ...\r\n",
"Cc: ...\r\n",
"Subject: ...\r\n",
"Content-Type: application/x-msdownload; name=\"" FILENAME "\"\r\n",
"Content-Transfer-Encoding: base64\r\n",
"Content-Disposition: attachment; filename=\"" FILENAME "\"\r\n",
fileBuf
}
Esta es el error me arroja la consola
cannot initialize an array element of type 'const char *' with an value of type 'char (*)[76]'
file
^---
Espero haberme explicado bien.
static char (*file)[76] = NULL;
¿Qué intentaste hacer? No le veo ningún sentido. ¿De dónde sale el 76 o qué significa?file
? En el código no aparece declarada la variable, y el 76 todavía no sé lo que es.