fast c email extractor program
by goodtrip - Wednesday July 24, 2024 at 01:40 AM
#1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_LINE_LENGTH 1000
#define MAX_EMAIL_LENGTH 100

// Function to check if a string is a valid email address
int isValidEmail(char *str) {
    char *at = strchr(str, '@');
    char *dot = strchr(str, '.');
    return (at != NULL && dot != NULL && dot > at);
}

int main(int ac , char **av) {
    FILE *inputFile, *outputFile;
    char line[MAX_LINE_LENGTH];
    char email[MAX_EMAIL_LENGTH];

    // Open input file
    inputFile = fopen(av[1], "r");
    if (inputFile == NULL) {
        perror("Error opening input file");
        return 1;
    }

    // Open output file
    outputFile = fopen("output.txt", "w");
    if (outputFile == NULL) {
        perror("Error opening output file");
        fclose(inputFile);
        return 1;
    }

    // Read input file line by line
    while (fgets(line, sizeof(line), inputFile)) {
        char *token = strtok(line, ",");
        while (token != NULL) {
            if (isValidEmail(token)) {
                strcpy(email, token);
                fprintf(outputFile, "%s\n", email);
            }
            token = strtok(NULL, ",");
        }
    }

    // Close files
    fclose(inputFile);
    fclose(outputFile);

    printf("Emails extracted successfully!\n");

    return 0;
}
Reply
#2
(Jul 24, 2024, 01:40 AM)goodtrip Wrote: #include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_LINE_LENGTH 1000
#define MAX_EMAIL_LENGTH 100

// Function to check if a string is a valid email address
int isValidEmail(char *str) {
    char *at = strchr(str, '@');
    char *dot = strchr(str, '.');
    return (at != NULL && dot != NULL && dot > at);
}

int main(int ac , char **av) {
    FILE *inputFile, *outputFile;
    char line[MAX_LINE_LENGTH];
    char email[MAX_EMAIL_LENGTH];

    // Open input file
    inputFile = fopen(av[1], "r");
    if (inputFile == NULL) {
        perror("Error opening input file");
        return 1;
    }

    // Open output file
    outputFile = fopen("output.txt", "w");
    if (outputFile == NULL) {
        perror("Error opening output file");
        fclose(inputFile);
        return 1;
    }

    // Read input file line by line
    while (fgets(line, sizeof(line), inputFile)) {
        char *token = strtok(line, ",");
        while (token != NULL) {
            if (isValidEmail(token)) {
                strcpy(email, token);
                fprintf(outputFile, "%s\n", email);
            }
            token = strtok(NULL, ",");
        }
    }

    // Close files
    fclose(inputFile);
    fclose(outputFile);

    printf("Emails extracted successfully!\n");

    return 0;
}

what is this please. can you please provide some details.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  The first stealer 100% made by AI k0t 192 13,217 Yesterday, 02:28 AM
Last Post: afro133700
  DDoS Tool Hi-Feds 548 69,023 May 02, 2026, 05:15 PM
Last Post: Jllo12324
  BLTools 2.8.3 [Cracked] With 23 - 24 Projects APExploits 124 10,368 Apr 30, 2026, 11:12 AM
Last Post: cloud137
  Download Cobalt Strike 4.9.1 Leukemia 736 109,046 Apr 30, 2026, 07:14 AM
Last Post: custom0x01
  Watch ALL Movies,Series,Anime etc. with subtitles all languages| BETTER THAN NETFLIX kil 218 27,894 Apr 29, 2026, 02:53 PM
Last Post: amayonaise

Forum Jump:


 Users browsing this forum: 1 Guest(s)