This is what I have so far. This isn't working and this isn't even close to working. I'm not that experienced at C++ so I was hoping that someone would help me please. The assignment is basically to write a code to validate an email address to see what characters are allowed and what characters aren't allowed. Please help in anyway possible.
Thank you.
// reading a text file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int spc_email_isvalid(const char *address) {
int count = 0;
const char *c, *domain;
static char *specialchars = "()<>@,;:\\\"[]";
// validate the name portion (name@domain)
for (c = address; *c; c++) {
if (*c == '\"' && (c == address || *(c - 1) == '.' || *(c - 1) ==
'\"')) {
while (*++c) {
if (*c == '\"') break;
if (*c == '\\' && (*++c == ' ')) continue;
if (*c < ' ' || *c >= 127) return 0;
}
if (!*c++) return 0;
if (*c == '@') break;
if (*c != '.') return 0;
continue;
}
if (*c == '@') break;
if (*c <= ' ' || *c >= 127) return 0;
if (strchr(specialchars, *c)) return 0;
}
if (c == address || *(c - 1) == '.') return 0;
// validate the domain portion (name@domain)
if (!*(domain = ++c)) return 0;
do {
if (*c == '.') {
if (c == domain || *(c - 1) == '.') return 0;
count++;
}
if (*c <= ' ' || *c &>= 127) return 0;
if (strchr(specialchars, *c)) return 0;
} while (*++c);
return (count >= 1);
}
*/