Codice: Seleziona tutto
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
int main()
{
string keyword;
string messaggio;
int crypted;
int real_difference;
int i=0;
int k;
int l;
cout<<"Enter the keyword : ";
getline(cin, keyword);
cout<<"Enter the message you want to crypt : ";
getline(cin, messaggio);
k = keyword.length();
l = messaggio.length();
loop1:
if(k < l); //used to even out the keyword and the sentence
{ //to change each letter
keyword = keyword + keyword;
k = keyword.length();
if(k < l)
goto loop1;
}
cout<<"\n\n";
while (i<= messaggio.length()) //records length and uses string as array
{
keyword[i] -= 'a'- 1;
if((messaggio[i] + keyword[i]) > 'z') //If crypted letter goes beyond 'z'
crypted = 'a' + (keyword[i]+messaggio[i] - 'z') - 1;
else if(messaggio[i] == 32) // If letter is a space
crypted = messaggio[i];
else
crypted = messaggio[i] + keyword[i]; //Crypting
cout<<(char)crypted; //Prints out the crypted letter
i++;
if(i>= messaggio.length())
break;
}
return 0;
}
Codice: Seleziona tutto
cd '/root/prova/debug/./src' && WANT_AUTOCONF_2_5="1" WANT_AUTOMAKE_1_6="1" LC_MESSAGES="C" LC_CTYPE="C"
gmake -k prova
compilazione di main.cpp (g++)
In file included from /usr/lib/gcc/i486-slackware-linux/4.2.4/../../../../include/c++/4.2.4/backward/iostream.h:31,
from /root/prova/src/main.cpp:1:
/
usr/lib/gcc/i486-slackware-linux/4.2.4/../../../../include/c++/4.2.4/backward/backward_warning.h:32:2: warning:
#warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard.
Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>.
To disable this warning use -Wno-deprecated.
/root/prova/src/main.cpp:65:10: warning: no newline at end of file
/root/prova/src/main.cpp:
In function 'int main()':
/root/prova/src/main.cpp:8: error: 'string' was not declared in this scope
/root/prova/src/main.cpp:8: error: expected `;' before 'keyword'
/root/prova/src/main.cpp:9: error: expected `;' before 'messaggio'
/root/prova/src/main.cpp:17: error: 'keyword' was not declared in this scope
/root/prova/src/main.cpp:22: error: 'messaggio' was not declared in this scope
/root/prova/src/main.cpp:28: warning: empty body in an if-statement
/root/prova/src/main.cpp:11: warning: unused variable 'real_difference'
gmake: *** [main.o] Error 1
gmake: Target `prova' not remade because of errors.
*** Uscito con stato: 2 ***
grazie