streams implementation in C