Help with trying to kill repeat function
I'm a bit new to C, and I supposed to code a program that prompts for a character, and then will echo the same character, ascii and hex equiv. of that character. It is supposed to repeat the process, prompting again, and will keep going until the user inputs a ! character. I can't figure out why the ! isant killing the program.
all help is much appreciated, this is my first post here, and look forward to being an active, responseable member. Thanks!
my code:
Code:
#include <stdio.h>
#define FLAG '!'
int instruct();
int getval();
int displayval();
int repeat();
int main()
{
char car;
instruct();
car = getval();
displayval();
while (car != FLAG)
{
repeat();
}
return (0);
}
int instruct()
{
printf("Please enter a (character) value: \n");
return (0);
}
int getval()
{
char car;
car = getc(stdin);
fpurge(stdin);
return (0);
}
int displayval()
{
char car;
printf("Character: %c\t ascii: %u\t hex: %#X\n", car, car, car);
return (0);
}
int repeat()
{
instruct();
getval();
displayval();
return (0);
}