Saturday, May 22, 2010

Simple C++ Encryption/Decryption Program. What am I doing wrong??????????????

Output should be:


Encrypted string is: uijt!jt!b!tfdsfu"


Decrypted string is: this is a secret!





Here is my code:


#include %26lt;iostream %26gt;


using std :: cout;


using std :: endl;


void encrypt( char [ ] ); // prototypes of functions used in the code


void decrypt( char * ePtr );


int main( )


{


// create a string to encrypt


char string[ ] = "this is a secret!";


cout %26lt;%26lt; "Original string is: " %26lt;%26lt; string %26lt;%26lt; endl;


encrypt( string );


// call to the function encrypt( )


cout %26lt;%26lt; "Encrypted string is: " %26lt;%26lt; string %26lt;%26lt; endl;


decrypt( string );


// call to the function decrypt( )


cout %26lt;%26lt; "Decrypted string is: " %26lt;%26lt; string %26lt;%26lt; endl;


return 0;


{ // main


//encrypt data


void encrypt (char e[] ) {


for( int i=0; e[i] != '= '\0'; ++i ) ++e[i];


} // encrypt





//decrypt data


void decrypt( char *ePtr ) {


for( ; *ePtr != '\0'; ==ePtr ) --(*ePtr);





I have tried moving code around to fix errors I get but I cant seem to get this to compile.

Simple C++ Encryption/Decryption Program. What am I doing wrong??????????????
What is the compiler error?
Reply:ok from what I see in your code is you are missing a few }.





right after int main() you have {


Also you have one at // main and one at void encrypt (char e ){


on the last // encrypt there is one }.


and at the line that sais void decrypt(char*ePtr) you have {.





For each of these { you need to have a closing }. You only have 1 } in your entire code, so i suggest to go and look it over and put the } in where they belong so that every one of { will have a }.





Good Luck

strawberry

No comments:

Post a Comment