No Output to file

So, my program will compile. However, Something in this function is not sending my cryptogram file out to the encrypt02.txt file. Help?


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
void CryptEncryption(vector<string>Original)
{
  vector<string>Cryptogramfile;
  string word1;
  string cryptKey;
  int slot;
  ifstream  fin;


  fin.open("originaltext.txt");
  while(!fin.eof())
    {
      fin >> word1;
      Original.push_back(word1);
    }

  fin.close();

  cryptKey = "wyijkcuvdpqlzhtgabmxefonrs";

  for(int i = 0; i < Original.size(); i++)
    {
    for (int j = 0; j < Original[i].size(); j++)
      {
        slot = Original[i][j] - 'a';
        Original[i][j] = cryptKey[slot];
      }

Cryptogramfile.push_back(Original[i]);

ofstream fou;
fou.open("encrypt02.txt");//creates file for vector                                                \
                                                                                                    
for (int i = 0; i < Cryptogramfile.size(); i++)
{
  fou << Cryptogramfile[i];
}
 fou.close();
    }
}
Is your first while loop getting stuff from the first file? Is the Original vector getting stuff in it?
I have a function that puts stuff into the Original vector that I call in my menu function.

I call the GetFileintoVector(Original) function in the beginning, and that function also gets used in EnryptRot function. Do I need to call it again somewhere?

This function comes before the CryptEncryption function
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
void Menu()
  {
    vector<string>Original;
    vector<string>EncryptedFile;
    int decision;
    int decision2;
    int decision3;
    int key;
    int key2;
    GetfileintoVector(Original);
    cout << "Hello User! Are you encrypting(1) or decrypting(2)?" << endl;
    cin >> decision;
    if(decision == 1)
      {
      cout << "Okay! Do you want to use Rot(1) or Cryptogram(2)?" << endl;
      cin >> decision2;

      if(decision2 == 1)
        {
        cout << "What is the encryption Rot key?" << endl;
        cin >> key;
        EncryptRot(Original, key);
        }
      }

    else if(decision2 == 2)
CryptEncryption(Original);

     else if(decision == 2)
        {
        cout << "Okay! Are we using Rot(1) or Cryptogram(2)?" << endl;
        cin >> decision3;
            if(decision3 == 1)
              {
                cout << "What is the decryption Rot key?" << endl;
                cin >> key2;
                DecryptRot(EncryptedFile, key2);
              }
        }
  }
I'm asking if the Original vector actually has something in it before you actually start printing it to the file.

Can you check?
 
cout <<  Original.size(); 

or something
Last edited on
Topic archived. No new replies allowed.