468,136 Members | 1,469 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,136 developers. It's quick & easy.

cipher problems help please due in 30 minutes

2
ok the part that i had earlier was supposed to part of this cipher, im having trouble with it not converting spaces
Expand|Select|Wrap|Line Numbers
  1.     char ch;
  2.     char inputfile[81];
  3.     cout << "enter input filename:"<<endl;
  4.     cin.getline(inputfile, 81);
  5.     char outputfile[81];
  6.     cout << "enter output filename:"<<endl;
  7.     cin.getline(outputfile, 81);
  8.     string keyword;
  9.     cout << "enter keyword:" << endl;
  10.     getline(cin, keyword);
  11.     ifstream infile;
  12.      ofstream oufile;
  13.      infile.open (inputfile);
  14.      oufile.open (outputfile);
  15.     if (!outputfile)
  16.      {
  17.          cout << "ERROR: CANNOT OPEN output file FILE\n";
  18.          return 5;
  19.      }
  20.     else if (!inputfile)
  21.      {
  22.          cout << "ERROR: CANNOT OPEN input file FILE\n";
  23.          return 6;
  24.      }
  25.  
  26.  
  27.     int answer = menu();
  28.  
  29.  
  30.     if ( answer == 1)
  31.     {
  32. >>        for(int i=0; infile >> ch  ; i = (i+1)% keyword.length())
  33.         {
  34.             ch =ch+keyword[i];
  35.             oufile << ch;
  36.         }
  37.     }
  38.     else if ( answer == 2)
  39.     {
  40. >>        for(int i=0; infile >> ch ; i = (i+1)% keyword.length())
  41.         {
  42.             ch =ch-keyword[i];
  43.             oufile << ch;
  44.         }
  45.     }
  46.     infile.close ();
  47.     oufile.close ();
  48.  
  49.     return 0;
  50. }
  51. int menu ()
  52. {
  53.     int r;
  54.     do 
  55.     {    cout << "for encryption enter 1, for decryption enter 2, and to quit "; 
  56.         cout <<    "enter 3"<< endl;
  57.         cin >> r;
  58.     }    while ( r != 1 && r != 2 &&  r != 3);
  59.         return r;
  60. }
  61.  
here are the warnings i am getting:
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
Mar 25 '08 #1
1 1315
ckking
2
ok, i changed it because the infinite loop was caused by the upload site having the loop first
Mar 25 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Michael Sparks | last post: by
4 posts views Thread by Carl Harris | last post: by
7 posts views Thread by Piotr Turkowski | last post: by
9 posts views Thread by Piotr Turkowski | last post: by
2 posts views Thread by Julio C. Hernandez Castro | last post: by
16 posts views Thread by Cawas | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.