Get all mail addresses from the file (source code)

zhaozj2021-02-08  348

I really want to implement an EREG feature similar to the PHP function. Welcome to

/ * * Get the email address from the file 2003-2-8 17:15 * / # include #include #define mailmaxlen 20 # define bufmaxlen 200

Long FileSize (file * stream) {long curpos, length; curpos = fteam; fseek (stream, 0l, seek_ek; length = ftell (stream); FSeek (stream, curpos, seek_set); return length;}

INT Main (int Argc, char * argv []) {file * fp, * fp_write; int i, temp_len; int bag_find = 0, BOOL_FINISHED = 0; long file_len = 0; char filename [30], Write_File [30]; CHAR MAIL_DATA [50]; // Save the temporary mail char * buf; char * p, * mail_begin, * temp_p; if (argc! = 2) {Printf ("Error! / NEXP:% s YourMail.dat / N ", argv [0]); return 0;} sprintf (Write_File," TMP_% S ", argv [1]); // Generate file names to be written STRCPY (FileName, Argv [1]); if ((((((((((( FP = FOPEN (FileName, "RB"))) == NULL) {Printf ("/ Ncan't Open THE FILE% S To Read! / N", FileName); Printf ("Press any key to halt!") Return (0);

IF ((FP_WRILE, "W") == NULL) {Printf ("/ Ncan't Open THE FILE for% S to Write! / N", FP_WRITE); Printf ("Press Any Key to Halt) ! "); Return (0);

File_len = filesize (fp); buf = (char *) malloc (file_len); Fread (buf, file_len, 1, fp); for (P = BUF; * P! = '/ 0'; p ) {// if (* p == '_' || * p == '.' || (* p> = '0' && * p <= '9') || (* p> = 'a' && * P < = 'Z') || (* p> = 'a' && * p <= 'z')))

IF (* p == '@') {bool_finished = 0; bool_find = 0; mail_begin = p; temp_len = 0; while (Temp_len =' 0 '&& * p <=' 9 ') || (* p> =' a '&& * p <=' z ') || (* p> =' a '&& * p <=' z ')) {TEMP_LEN ;} else {Break;} } P ; // Point to the correct start // EREGI ("^ [_ /. 0-9a-z -] @ ([0-9a-z] [0-9a-z -] /.) [ AZ] {2, 3} $ ", $ emil)) if (mail_begin! = p) // Equity Condition {TEMP_P = mail_begin; // This time TEMP_P points @ 处 Mail_Begin = P; // Record the mail name start address P = temp_p; // p pointing to the first character // printf ("% s% c", "ok", * temp_p) after @

// The next first character should be a while between AZ 0-9 ((* p> = '0' && * P <= '9') || (* p> = 'a' && * P < = 'Z') || (* p> = 'a' && * p <= 'z') && * p! = '/ 0') {p ; // Keeping should be AZ - IF (* p = = '-' || (* p> = '0' && * p <= '9') || (* p> = 'a' && * p <= 'z') || (* p> = ' A '&& * p <=' z ')) {p ;} else {bool_find = 0; Break;} temp_len = 0; //cd.digital@cfan.com.cn while (Temp_len = '0' && * p <= '9') || (* p> = 'a' && * p <= ' Z ') || (* p> =' a '&& * p <=' z ')) {p ; temp_len ;} // else if (* p ==') // find some point. [ AZ] {2, 3} $ {bool_find ; // Find a TEMP_P = P; // Temp_P pointing. The location P ; Break;} else {bool_finished = 1; // Exit cycle break;}} // while (Temp_len 0) {p = TEMP_P; // P back to the last one. The position P = P 3; if (! (* P> = ' A '&& * p <=' z ') || (* p> =' A '&& * p <=' z ')))) // The last .NET does not match {p -;} / * for (TEMP_P = Mail_Begin; TEMP_P <= P;

TEMP_P ) {Printf ("% C", * temp_p);} * /// Strncpy (Mail_Data, Mail_Begin, 3); FWRITE (Mail_Begin, P-Mail_Begin 1, 1, FP_WRITE); FPUTC ('/ n', FP_WRITE); // Printf ("% c", '/ n'); * p = ''; // This is to start from this time}} // if (* p == '@') // Printf ("% c", * p);} // for fclose (fp); fclose (fp_write); free (buf); printf ("/ n ----------- ------- / Nok! "); Printf (" / Nfile WriteD to '% S'! ", Write_File; Return (0);}

转载请注明原文地址:https://www.9cbs.com/read-814.html

New Post(0)