Checking validity of input character
I'm writing a program for a university assignment, its on encryption,
the program has to ask user for input (printable ascii characters only)
with max 6 lines of input with 128 characters per line,
then it ask for a number between 1 and 72 to use as an encryption key,
and that number is used as part of an algorithm to encode the message.
I have many problems with this, but im really struggling with one in particular, where it asks for the number, it has to check that that number is between 1 and 72, if they enter an invalid number it has to keep asking until it gets a valid one, here's the code i've got:
Code:
void getKey(int *key)
{
do
{
printf("\nEnter a number between 1 an 72\n");
scanf("%d", &key);
if (key < 1 || key > 72)
{
printf("Invalid number entered\n");
key = 0;
}
} while(key=0);
}
error message is that i'm comparing between pointers and integers in the if statement, which i can see, but i cant find a solution. Can anyone help?