Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This is a program that accepts emails inputted
- -by the user and determines if they're spam emails
- By: Henry Bennett
- */
- // read in libraries to use
- #include<stdio.h>
- #include<conio.h>
- #include<string.h>
- // set max array limit for emails and scam words
- #define SIZE 150
- // main body
- main(){
- // scam words to look for
- char word1[SIZE] = "free";
- char word2[SIZE] = "congradulations";
- char word3[SIZE] = "winner";
- char word4[SIZE] = "win";
- char word5[SIZE] = "instantly";
- char word6[SIZE] = "click";
- char word7[SIZE] = "download";
- char word8[SIZE] = "scam";
- char word9[SIZE] = "money";
- char word10[SIZE] = "lifetime";
- // email varriable
- char userEmail[SIZE];
- // spamScore counter
- int spamScore = 0;
- // clear console and prompt user for email to be scanned
- clrscr();
- printf("\nEnter in an email to be scanned: ");
- fgets(userEmail, 100, stdin);
- // print out user input for the email
- printf("\nThe email you entered is: %s",&userEmail);
- // compare the email for certain words
- if(strstr(userEmail,word1) != NULL){
- spamScore += 1;
- }
- if(strstr(userEmail,word2) != NULL){
- spamScore += 1;
- }
- if(strstr(userEmail,word3) != NULL){
- spamScore += 1;
- }
- if(strstr(userEmail,word4) != NULL){
- spamScore += 1;
- }
- if(strstr(userEmail,word5) != NULL){
- spamScore += 1;
- }
- if(strstr(userEmail,word6) != NULL){
- spamScore += 1;
- }
- if(strstr(userEmail,word7) != NULL){
- spamScore += 1;
- }
- if(strstr(userEmail,word8) != NULL){
- spamScore += 1;
- }
- if(strstr(userEmail,word9) != NULL){
- spamScore += 1;
- }
- if(strstr(userEmail,word10) != NULL){
- spamScore += 1;
- }
- // determine what the spam score is, suggest if its spam to user
- if (spamScore == 0)
- {
- // not spam
- printf("\nYour spamScore is %d, its not spam!", spamScore);
- }
- else if (spamScore <= 1)
- {
- // might be spam
- printf("\nYour spamScore is %d, its probably spam.", spamScore);
- }
- else
- {
- // is spam
- printf("\nYour spamScore is %d, its spam.", spamScore);
- }
- // return value
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement