input and if

Simple solution, found it on my own.
The solution is to write:

if (buf[6] == '6') {

instead of

if (buf[6] == 6) {

I do not technically why but it works.