0

How can I ask the user to write his Email, once the user end to enter his Email, he will press 'Space' button instead of 'Enter' or the program will write an error massage and ask him to write the Email again.

I have to use a limited option like : just in library of :stdio.h and stlib.h.

Rob
  • 14,746
  • 28
  • 47
  • 65

2 Answers2

0

It's not possible with just a C library, as it's OS-dependent. For the *nix-like OSes you can use code from the following answer: https://stackoverflow.com/a/1798833/954532

Community
  • 1
  • 1
nightuser
  • 664
  • 4
  • 13
0

You can't do that from a typical terminal because of how the terminal buffers input. Basically, the behavior of your program not being able to see input before the user hits enter (and therefore sends a newline) is not configurable from your code using standard libraries.

You can still do this by using external libraries (which you say you cannot use) such as ncurses; though technically you can just perform some magic termioss and/or ioctls on your terminal as well to copy some of that behavior on many Unix-like systems.

Mark Nunberg
  • 3,551
  • 15
  • 18
  • exactly what i discovered ,but it's not make sense .. maybe i have not read the assignment well .. but the assignment is to write an Email with only small and big letters ,dot ,_ and @ and when i finish press "space" button to end the input.. – Aviv Perets Apr 02 '16 at 14:51