Output should be:
Encrypted string is: uijt!jt!b!tfdsfu"
Decrypted string is: this is a secret!
Here is my code:
#include <iostream >
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 << "Original string is: " << string << endl;
encrypt( string );
// call to the function encrypt( )
cout << "Encrypted string is: " << string << endl;
decrypt( string );
// call to the function decrypt( )
cout << "Decrypted string is: " << string << 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.
Ok i fixed most of it now. Here is my error Line 28 expected primary-expression before '==' token
#include <iostream >
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 << "Original string is: " << string << endl;
encrypt( string );
// call to the function encrypt( )
cout << "Encrypted string is: " << string << endl;
decrypt( string );
// call to the function decrypt( )
cout << "Decrypted string is: " << string << 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);
}
Related posts:








2 responses so far ↓
1 SPB // Apr 28, 2008
What is the compiler error?
2 Crystal // Apr 28, 2008
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
Leave a Comment