Hello
I apologize for my poor english
I'm a italian old retired, I hope to increase my mind's performances trying to resolve my problems using c++.
I'm trying with this program to recover emails in a file processable in Excel or access.
the program works fine recovering all emails, but the last recursive sector of any email stops at the first RETURN of the message, instead i need that the catching works until the end of the text of any email.
Some one can help me to get what i need?
many thanks
Ettore
hereunder my program
---------------------------------------------
Code:#include <stdio.h>
#include <string.h>
main(argc, argv)
int argc;
char *argv[];
{
char strAppo[1001];
char strAppo1[1001];
char FileOut[256];
int lenstr;
FILE *pfIn, *pfOut;
char *pDest;
if ((pfIn = fopen(argv[1], "r")) == NULL)
{
printf ("Errore apertura file %s", argv[1]);
return(-1);
}
sprintf(FileOut, "%s.out", argv[1]);
if ((pfOut = fopen(FileOut, "w")) == NULL)
{
printf ("Errore apertura file %s", FileOut);
return(-2);
}
while(!feof(pfIn))
{
fgets(strAppo,1000,pfIn);
pDest = strstr(strAppo, "Date:");
if (pDest != NULL)
{
strAppo1[0] = 0;
lenstr = strlen(pDest + 5);
strncpy (strAppo1, pDest + 5, lenstr - 1);
strAppo1[lenstr - 1] = 0;
fputs(strAppo1, pfOut);
}
pDest = strstr(strAppo, "Nome:");
if (pDest != NULL)
{
strAppo1[0] = 0;
lenstr = strlen(pDest + 5);
strncpy (strAppo1, pDest + 5, lenstr - 1);
strAppo1[lenstr - 1] = 0;
fputs("|", pfOut);
fputs(strAppo1, pfOut);
}
pDest = strstr(strAppo, "Email:");
if (pDest != NULL)
{
strAppo1[0] = 0;
lenstr = strlen(pDest + 6);
strncpy (strAppo1, pDest + 6, lenstr - 1);
strAppo1[lenstr - 1] = 0;
fputs("|", pfOut);
fputs(strAppo1, pfOut);
}
pDest = strstr(strAppo, "Cognome:");
if (pDest != NULL)
{
strAppo1[0] = 0;
lenstr = strlen(pDest + 8);
strncpy (strAppo1, pDest + 8, lenstr - 1);
strAppo1[lenstr - 1] = 0;
fputs("|", pfOut);
fputs(strAppo1, pfOut);
}
pDest = strstr(strAppo, "Messaggio:");
if (pDest != NULL)
{
strAppo1[0] = 0;
lenstr = strlen(pDest + 10);
strncpy (strAppo1, pDest + 10, lenstr - 1);
strAppo1[lenstr - 1] = 0;
fputs("|", pfOut);
fputs(strAppo1, pfOut);
fputs("\n", pfOut);
}
}
fclose(pfIn);
fclose(strAppo);
return(0);
}