i have the followingBoth functions only get passed the first element of the encrypt array.Code:#include <stdio.h> #include <stdlib.h> void Decrypt( char *, char * ); void Get_Password( char *, char * ); int main() { char Text[] = "TOMORROW NEVER DIES"; char Pword[] = "hello"; char Encrypted[20] = { '\0' }; char *crypt = NULL; for ( int j = 0, i = 0; Text[i]; i++) { Encrypted[i] = Text[i] ^ Pword[j]; if ( j == 4 ) j = 0; else ++j; ++i; } //Decrypt( Encrypted, Pword ); crypt = Encrypted; Decrypt( crypt, Pword ); Get_Password( crypt, Text ); return 0; } void Decrypt( char *Encrypted, char *Pword ) { for ( int j = 0, i = 0; i < 20 ; i++ ) { printf("%c", Encrypted[i] ^ Pword[j]); if ( j == 4 ) j = 0; else ++j; } putchar('\n'); } void Get_Password( char *Encrypted, char *Text ) { for ( int j = 0, i = 0; i < 20 ; i++, j++ ) { printf("%c", Encrypted[i] ^ Text[j]); } putchar('\n'); }
Since i was told there is no need to tell the function to expect an array ie char [] and to use char * as the name of the array was effectively a pointer anyway. That is what i have been doing and has worked the last week or so. It even works for the password but not the encrypt string.