Expand|Select|Wrap|Line Numbers
- char ch;
- char inputfile[81];
- cout << "enter input filename:"<<endl;
- cin.getline(inputfile, 81);
- char outputfile[81];
- cout << "enter output filename:"<<endl;
- cin.getline(outputfile, 81);
- string keyword;
- cout << "enter keyword:" << endl;
- getline(cin, keyword);
- ifstream infile;
- ofstream oufile;
- infile.open (inputfile);
- oufile.open (outputfile);
- if (!outputfile)
- {
- cout << "ERROR: CANNOT OPEN output file FILE\n";
- return 5;
- }
- else if (!inputfile)
- {
- cout << "ERROR: CANNOT OPEN input file FILE\n";
- return 6;
- }
- int answer = menu();
- if ( answer == 1)
- {
- >> for(int i=0; infile >> ch ; i = (i+1)% keyword.length())
- {
- ch =ch+keyword[i];
- oufile << ch;
- }
- }
- else if ( answer == 2)
- {
- >> for(int i=0; infile >> ch ; i = (i+1)% keyword.length())
- {
- ch =ch-keyword[i];
- oufile << ch;
- }
- }
- infile.close ();
- oufile.close ();
- return 0;
- }
- int menu ()
- {
- int r;
- do
- { cout << "for encryption enter 1, for decryption enter 2, and to quit ";
- cout << "enter 3"<< endl;
- cin >> r;
- } while ( r != 1 && r != 2 && r != 3);
- return r;
- }
warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
at the arrow
and i get the menu to work , but when i upload it the the website it loops infinitely