I may me a little off at the moment, but this does exactly the same as when text is global.
Code:
int main(void)
{
char text[100];
char decision[10];
printf("Enter text to be encrypted:");
fgets(text, sizeof(text), stdin);
text[strlen(text)-1] = '\0';
encrypt(text);
printf("%s\n", text);
printf("Do you want to decrypt the string?(yes/no)\n");
fgets(decision, sizeof(decision), stdin);
decision[strlen(decision)-1] = '\0';
if (strcmp(decision, "yes") == 0)
{
decrypt(text);
printf("%s\n", text);
}
return 0;
}
unless i used a pointer to the variable
These are passing pointers.
Code:
void encrypt(char[]);
void decrypt(char[]);