email parser need help asap!

so i need help for some reason it searchs through for a valid email but still prints the whole text?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

bool isValidEmailCharacter(char c)
{
  bool result = false; 
  if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z' && c <= '9') || (c == '.')|| (c == '-')||
     (c == '+')|| (c == '_')) 
     result = true;

  return result;
}

int main()
{
  ifstream fin;
  string fileName;
  string dFileName ="fileContainingEmails.txt";
  cout << "What is the file called?";
  getline(cin,fileName);
  fin.open (fileName.c_str());

  ofstream fout;
  string outFileName;
  string dOutFileName ="copyPasteMyEmails.txt";
  cout << "What file do you want to use for output?";
  getline(cin, outFileName);
  fout.open(outFileName.c_str());

  if (fileName.length() == 0)
  {
    fileName = dFileName;
    outFileName = dOutFileName;
  }

  const int MAX_EMAILS = 1000;
  int nEmails = 0;
  string email[MAX_EMAILS];

  while(true)
  {
    if (!fin.good()) break;
    int s;
    int e;
    string lineFromFile;
    getline(fin, lineFromFile);

  for (int i = 0; i < lineFromFile.length(); i++) // for each character in the string
  {
    
    if(lineFromFile[i] == '@')
      lineFromFile[i]++;
    {

      for (s = i; s >= 0; s--)
      {
        if (!isValidEmailCharacter(lineFromFile[s]));
      
      for (e = i; e < lineFromFile.length(); e++)
      {
        if (!isValidEmailCharacter(lineFromFile[e])) break;
      
  if (nEmails > MAX_EMAILS)
    email[nEmails++] = lineFromFile;
  
      }
    }
  }
}
  cout << lineFromFile << "; " << endl;
  fout << lineFromFile << "; " << endl;
}
fout.close();
fin.close();

return 0;
}
Format your code at look at it again...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

bool isValidEmailCharacter(char c)
{
	bool result = false; 
	if(
		(c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z' && c <= '9') || (c == '.')|| (c == '-')||
		(c == '+')|| (c == '_')
	)
		result = true;
	return result;
}

int main()
{
	ifstream fin;
	string fileName;
	string dFileName ="fileContainingEmails.txt";
	cout << "What is the file called?";
	getline(cin,fileName);
	fin.open (fileName.c_str());

	ofstream fout;
	string outFileName;
	string dOutFileName ="copyPasteMyEmails.txt";
	cout << "What file do you want to use for output?";
	getline(cin, outFileName);
	fout.open(outFileName.c_str());

	if (fileName.length() == 0)
	{
		fileName = dFileName;
		outFileName = dOutFileName;
	}

	const int MAX_EMAILS = 1000;
	int nEmails = 0;
	string email[MAX_EMAILS];

	while(true)
	{
		if (!fin.good()) break;
		int s;
		int e;
		string lineFromFile;
		getline(fin, lineFromFile);

		for (int i = 0; i < lineFromFile.length(); i++) // for each character in the string
		{
			if(lineFromFile[i] == '@')
				lineFromFile[i]++;
			{
				for (s = i; s >= 0; s--)
				{
					if (!isValidEmailCharacter(lineFromFile[s]));
					for (e = i; e < lineFromFile.length(); e++)
					{
						if (!isValidEmailCharacter(lineFromFile[e])) break;
						if (nEmails > MAX_EMAILS)
							email[nEmails++] = lineFromFile;
					}
				}
			}
		}
		cout << lineFromFile << "; " << endl;
		fout << lineFromFile << "; " << endl;
	}
	fout.close();
	fin.close();

	return 0;
}
Im sorry but i just need help do not know what im doing wrong...
So why don't you take any suggestion? I answered to one of those thread like other did as well. You just ignored it. How could we help then?
Topic archived. No new replies allowed.