good day sir i need to create function that limits the user on their input like if would like them to only use numbers or characters like this one but you can input lots of characters and numbers i just scooped this code from the web



Code:
#include <conio.h>
#include <stdio.h>

main()
{
   char    ch;
   int     colour, xkey;

   clrscr();
   textmode(3);
   window(1,1,80,25);
   cputs("Please press a number key 1 - 7 to change foreground color or Q to quit: ");
   do
      {
      do
        {
	limitchar("1234567Qq",&ch,&xkey);
        }
      while (xkey != 0);
      if ((ch == 'Q') || (ch == 'q')) break;
	{
	   colour = (int)ch-48;
	   textcolor(colour);
	   printf("\n");
	   cputs("This text is now displayed in foreground colour ");
	   putch((int)ch);
	   printf("\n\n");
	   cputs("Please press a number key 1 - 7 to change foreground color again or Q to quit: ");
	}
      if ((ch == 'Q') || (ch == 'q')) break;
   }
   while ((ch != 'Q') || (ch != 'q'));
}


limitchar(char *s, char *pkey, int *pekey)
{
  char  chr;

  do
  {
    *pekey = 0;
    *pkey  = getch();
    if (*pkey == 0)
      {
	*pekey = 1;
	*pkey  = getch();
        break;
      }
    if (*pkey == 27)
      {
	*pekey = 1;
	*pkey  = getch();
        break;
      }
  }
  while ((chr = strchr(s,*pkey)) == NULL);
  putch(*pkey);
}