# getchar problem in C

Status
Not open for further replies.

#### AliBahar

##### Member level 2
Hi
as you know if we use getchar() function it waits for typing char by keyboard.
in my requirement the compiler must return to code and perform the next command line if there is no character typed with keyboard.
so after specified delay time the subsequent command must be performed if if there is no typed character .
any suggestion

#### horace1

which processor and compiler are you using

some libraries have a function which enables one to check if a character has been received
otherwise you can always check the UART receiver flag yourself

#### andre_teprom

##### Super Moderator
Staff member
You can input the value upon some condition like that:

Code C - [expand]1
2
3
4
if ( kbhit() )
{
variable= getch();
}

AliBahar

### AliBahar

points: 2

#### toastedsiopao

##### Newbie level 4
The problem with kbhit() is that the microcontroller must be in the kbhit(), for it to process the next line, better use an interrupt.

Status
Not open for further replies.