popening for read and write

How can 'popen()' be used for reading and writing to opening pipe?
If i try 'popen("prog", "rw")'
and then put and get chars - it does
not work.
What is wrong?

popen can't do rw because it's buffered. You will have to do your own fork()/exec() and fd manipulation.