String input problem, gets
hey, i'm having a problem with my input function. i've had the problem before.. but i dont remember what the solution is. for some reason, when my program hits the gets input it goes straight through it.. so how do i make this work? here's my code for this function:
Code:
void encrypt_text(int random_number, char *key)
{
char text[255];
char *pt;
int stringlength, counter;
if (random_number == 70) { --random_number; }
/* user input of string to be encrypted */
printf("\n\nEnter your text: ");
if ((pt = gets(text)) == NULL)
{
printf("\nError on input.\n");
}
/* find length of string entered */
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);
}