output type change int to char for cpu version
move stack buffer into function