fstream error

hello again everyone, The error is on line 52... any help will be appreciated!
Thanks!

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
#include<iostream>
#include<algorithm>
#include<windows.h>
#include<fstream>
#include<string>
#include<conio.h>


using namespace std;

int main()
{
    string text, filename;
    system("title encrypter");
    cout<<"Enter the file to encrypt: ";
    cin>>filename;
    filename = filename+".crypt";
    ofstream myfile(filename.c_str());
    Sleep(1250);
    system("cls");
    cout<<"Press escape to terminate typing.\nStart typing your message:\n";
    while(true)
    {
        getline(cin, text);
        replace(text.begin(), text.end(), 'a', ',');
        replace(text.begin(), text.end(), 'b', '<');
        replace(text.begin(), text.end(), 'c', '>');
        replace(text.begin(), text.end(), 'd', '?');
        replace(text.begin(), text.end(), 'e', '/');
        replace(text.begin(), text.end(), 'f', '|');
        replace(text.begin(), text.end(), 'g', '"');
        replace(text.begin(), text.end(), 'h', ':');
        replace(text.begin(), text.end(), 'i', ';');
        replace(text.begin(), text.end(), 'j', '}');
        replace(text.begin(), text.end(), 'k', '{');
        replace(text.begin(), text.end(), 'l', ']');
        replace(text.begin(), text.end(), 'm', '[');
        replace(text.begin(), text.end(), 'n', '+');
        replace(text.begin(), text.end(), 'o', '_');
        replace(text.begin(), text.end(), 'p', ')');
        replace(text.begin(), text.end(), 'q', '(');
        replace(text.begin(), text.end(), 'r', '*');
        replace(text.begin(), text.end(), 's', '&');
        replace(text.begin(), text.end(), 't', '^');
        replace(text.begin(), text.end(), 'u', '%');
        replace(text.begin(), text.end(), 'v', '$');
        replace(text.begin(), text.end(), 'w', '#');
        replace(text.begin(), text.end(), 'x', '@');
        replace(text.begin(), text.end(), 'y', '!');
        replace(text.begin(), text.end(), 'z', '~');
        replace(text.begin(), text.end(), ' ', '`');
        myfile<<text<<endl;
        if(getch() == VK_ESCAPE){
            cout<<endl<<"FINISHED!!!";
            system("pause");
            return 0;
        }
    }
    system("pause");
    return 0;
}
Last edited on
Please, do not double post. It clutters forums and spreads attempts to help you. Another thread: http://www.cplusplus.com/forum/beginner/155179/
oh sorry I thought I haven't posted the first one and that is why I posted it again, feel free to delete that post
Topic archived. No new replies allowed.