Simple word encrpt

Hi for some reason when words are entered there is a extra decrypt value ?
also how would i make scanf exept whitespaces so that a user could enter a sentence ?


int main(){
//what word was entered
char entered[100];
char encryped[100];
char decryped[100];
char *ptr;

puts("enter a word to encrypt");
//fgets(encrypted,100,stdin);
//getline(cin,);
//cin>>entered;
scanf("%s",entered);

//create new char array based on size of word entered
ptr = new char[strlen(entered)];


//populate newly created char[]
for(int t=0;t<strlen(entered);t++)
{
ptr[t] = entered[t];
}

//fill encryted[] with value
for(int t=0;t<sizeof(ptr);t++){

encryped[t] = (int)ptr[t];
}

printf("%s word was encrypted! \n");

//prints to scrren encrted word
for(int t =0;t<sizeof(ptr);t++){
printf("%d,",encryped[t]);

}


cout<<"\ndecrpted back again to !"<<endl;

//decrypt text
for(int t =0;t<sizeof(ptr);t++){


decryped[t] = (char)encryped[t];
printf("%c",decryped[t]);
}

printf("\n");

delete []ptr;

system("pause");
return 0;

}

Topic archived. No new replies allowed.