Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. /*
  2. This is a program that accepts emails inputted
  3. -by the user and determines if they're spam emails
  4.  
  5. By: Henry Bennett
  6. */
  7.  
  8. // read in libraries to use
  9. #include<stdio.h>
  10. #include<conio.h>
  11. #include<string.h>
  12.  
  13. // set max array limit for emails and scam words
  14. #define SIZE 150
  15.  
  16. // main body
  17. main(){
  18.  
  19. // scam words to look for
  20. char word1[SIZE] = "free";
  21. char word2[SIZE] = "congradulations";
  22. char word3[SIZE] = "winner";
  23. char word4[SIZE] = "win";
  24. char word5[SIZE] = "instantly";
  25. char word6[SIZE] = "click";
  26. char word7[SIZE] = "download";
  27. char word8[SIZE] = "scam";
  28. char word9[SIZE] = "money";
  29. char word10[SIZE] = "lifetime";
  30.  
  31. // email varriable
  32. char userEmail[SIZE];
  33.  
  34. // spamScore counter
  35. int spamScore = 0;
  36.  
  37. // clear console and prompt user for email to be scanned
  38. clrscr();
  39. printf("\nEnter in an email to be scanned: ");
  40. fgets(userEmail, 100, stdin);
  41.  
  42. // print out user input for the email
  43. printf("\nThe email you entered is: %s",&userEmail);
  44.  
  45. // compare the email for certain words
  46. if(strstr(userEmail,word1) != NULL){
  47. spamScore += 1;
  48. }
  49. if(strstr(userEmail,word2) != NULL){
  50. spamScore += 1;
  51. }
  52. if(strstr(userEmail,word3) != NULL){
  53. spamScore += 1;
  54. }
  55. if(strstr(userEmail,word4) != NULL){
  56. spamScore += 1;
  57. }
  58. if(strstr(userEmail,word5) != NULL){
  59. spamScore += 1;
  60. }
  61. if(strstr(userEmail,word6) != NULL){
  62. spamScore += 1;
  63. }
  64. if(strstr(userEmail,word7) != NULL){
  65. spamScore += 1;
  66. }
  67. if(strstr(userEmail,word8) != NULL){
  68. spamScore += 1;
  69. }
  70. if(strstr(userEmail,word9) != NULL){
  71. spamScore += 1;
  72. }
  73. if(strstr(userEmail,word10) != NULL){
  74. spamScore += 1;
  75. }
  76.  
  77. // determine what the spam score is, suggest if its spam to user
  78. if (spamScore == 0)
  79. {
  80. // not spam
  81. printf("\nYour spamScore is %d, its not spam!", spamScore);
  82. }
  83. else if (spamScore <= 1)
  84. {
  85. // might be spam
  86. printf("\nYour spamScore is %d, its probably spam.", spamScore);
  87. }
  88. else
  89. {
  90. // is spam
  91. printf("\nYour spamScore is %d, its spam.", spamScore);
  92. }
  93.  
  94. // return value
  95. return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement