473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1532
ckking
2
ok, i changed it because the infinite loop was caused by the upload site having the loop first
Mar 25 '08 #2

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

Similar topics

6
by: Michael Sparks | last post by:
Hi, I suspect this is a bug with AMK's Crypto package from http://www.amk.ca/python/code/crypto , but want to check to see if I'm being dumb before posting a bug report. I'm looking at...
4
by: Carl Harris | last post by:
I am trying to write some code to: 1.Prompt a user for filenames 2.Open the files 3.Convert my plain text into a cipher text array/string bear in mind I am a novice! I have wriiten some code...
7
by: Piotr Turkowski | last post by:
Hi! Here you can get some notes about Vigenere Cipher: http://raphael.math.uic.edu/~jeremy/crypt/vignere.html Here's whole code of my program, function stats() is in polish, so you can omit...
9
by: Piotr Turkowski | last post by:
Hi, The code is here: http://free.ud.pl/~piotr/data/vigenere.zip Its my program for decrypting and encrypting text. Shot polish course: szyfrowanie (szyfruj) - encrypting (text i want to code...
2
by: Julio C. Hernandez Castro | last post by:
Dear all, We have just developped a new block cipher called Raiden, following a Feistel Network structure by means of genetic programming. Our intention now consists on getting as much feedback...
1
by: beetle17 | last post by:
Plaintext: a  n i c e  d a y Key: -3 Ciphertext: X  k f Z b  a X v Cipher will accept commands from the user and perform the operations required by the commands. There are three different...
16
by: Cawas | last post by:
Cipher Lab produces some terminals to collect data where we can program using one implementation of plain C which I believe to be ANSI C89 compatible, although not fully. They have their on set of...
4
by: wagn31 | last post by:
i need to use a cipher but I have to used the assigned code in the ciphering i know how to do it, but i am not sure how to add my own dictionary. Here is what i have so far:
0
by: ntuyen01 | last post by:
Hi all, I want to use the SSLStream with the cipher (TLS_RSA_WITH_AES_128_CBC_SHA) to get the handshake with my server, but I not sure where I can start. I do it in C# 2.0 Here is my code: ...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.