ok the part that i had earlier was supposed to part of this cipher, im having trouble with it not converting spaces
[code=cpp]
char ch;
char inputfile[81];
cout << "enter input filename:"<<end l;
cin.getline(inp utfile, 81);
char outputfile[81];
cout << "enter output filename:"<<end l;
cin.getline(out putfile, 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;
}
[/code]
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
[code=cpp]
char ch;
char inputfile[81];
cout << "enter input filename:"<<end l;
cin.getline(inp utfile, 81);
char outputfile[81];
cout << "enter output filename:"<<end l;
cin.getline(out putfile, 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;
}
[/code]
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
Comment