I have a text file in which contains many emails, at the beginning of each email is 3 lines of header information, these include From:, Subject:, Date:. I know that after every ctrl-L character are the header lines, hence the c==12 line.
Currently my from array gets 1 line of text either something like:
From: Rollen Awen <[email protected]>
or
From: [email protected]
So right now I am trying to use delimiters to only keep the email address, but im not sure how to go about it. I have to be able to handle any type of situation, whether its enclosed within < > or if its enclosed between 2 white spaces.
For example, I want to change the
From: Rollen Awen <[email protected]> string into only [email protected]
Or changing
From: [email protected] into [email protected]
...
FILE *emaildata = fopen (argv[1], "r");
while((c=fgetc(emaildata))!=EOF){
if(c==12){
numberemails++;
fgets(nothing, sizeof(nothing), emaildata);
fgets(from, sizeof(from), emaildata);
fgets(subject, sizeof(subject), emaildata);
fgets(date, sizeof(date), emaildata);
//printf("%s", from);
}
...