thanks, it works. the problem was with the input buffer.. and the working code for my function now looks like this:
Code:
void encrypt_text(int random_number, char *key)
{
char text[255];
char *pt;
int stringlength, counter, ch;
system("cls");
if (random_number == 70) { --random_number; }
/* flush the input buffer */
while ((ch = getchar()) != '\n' && ch != EOF);
/* user input of string to be encrypted */
printf("\n\nEnter your text: ");
fgets(text, sizeof(text), stdin);
if ((pt = strchr(text, '\n')) != NULL)
{
*pt = '\0';
}
/* find the length of the entered string */
stringlength = strlen(text);
/* find string length for loop */
counter = 0;
do {
text[counter] = text[counter]^key[random_number];
printf("%c", text[counter]);
++counter;
} while (counter <= stringlength);
printf("\n\n");
}