/*************General Instructions********************
1. Compile this file in GCC compiler.
2. Double click/Run the .out file generated.
3. Give the complete path of files when asked.
*************************************************/
#include
#include < "string.h" >
int main(void)
{
char *sfile_name, *dfile_name, *chr_loc, temp_str[50];
FILE *sfile_ptr, *dfile_ptr;
int i = 0;
printf("\nEnter The Sourse Text File :");
scanf("%s", sfile_name);
printf("\nEnter The Destination Text File :");
scanf("%s", dfile_name);
sfile_ptr = fopen(sfile_name, "r");
dfile_ptr = fopen(dfile_name, "a+");
while(fscanf(sfile_ptr, "%s", temp_str) != EOF)
{
chr_loc = strchr(temp_str, '@');
if(chr_loc != NULL)
{
fprintf(dfile_ptr,"%s\n", temp_str);
printf("\nEntry #%d: %s", ++i, temp_str);
}
}
fclose(sfile_ptr);
fclose(dfile_ptr);
printf("\n\n%d-Email Addresses Found\n", i);
printf("All Entries Made into file %s\n\n", dfile_name);
return 0;
}
No comments:
Post a Comment