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
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
// 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
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);}