# C Issue WAIT FOR DIGIT

**URL:** <https://community.asterisk.org/t/c-issue-wait-for-digit/70493>\
**Category:** Asterisk APIs\
**Created:** [April 26, 2017, 2:56am UTC](https://community.asterisk.org/t/c-issue-wait-for-digit/70493 "2017-04-26T02:56:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tgwaste](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/tgwaste/32/1517_2.png) [@tgwaste](https://community.asterisk.org/u/tgwaste)\
**Post date:** [April 26, 2017, 2:56am UTC](https://community.asterisk.org/t/c-issue-wait-for-digit/70493/1 "2017-04-26T02:56:56Z")

</div>

Hi,  
Was playing around with AGI in C and couldn’t seem to get this to work, was wondering if anyone had any ideas?  
It answers but no matter what digit I hit it will wait the full 10 seconds before timing out and returning:  
200 result=0

```
> #include <stdio.h>
> #include <string.h>
> #include <strings.h>

> int main()
> {
> char buf[10240], line[1024];
> FILE *f;

> setlinebuf(stdout);
> setlinebuf(stderr);

> f = fopen("test.log", "a");

> if (!f) {
> return 0;
> }

> while (fgets(buf, sizeof(buf), stdin)) {
> buf[strlen(buf)-1] = '\0';
> if (*buf == 0) break;
> }

> fprintf(f, "answered\n");

> fprintf(stdout, "WAIT FOR DIGIT 10000\n");
> fflush(stdout);

> fgets(line,80,stdin);

> fprintf(f, "%s", line);
> fclose(f);

> return 1;
> }
```

---

<div class="post-metadata">

**Author:** ![tgwaste](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/tgwaste/32/1517_2.png) [@tgwaste](https://community.asterisk.org/u/tgwaste)\
**Post date:** [April 27, 2017, 6:20am UTC](https://community.asterisk.org/t/c-issue-wait-for-digit/70493/2 "2017-04-27T06:20:18Z")

</div>

This ended up working. It was a port blocking problem.
