It is easier to do this with command line options myprog -ams nnnnnn will do the job. there are also options like -gbs and -cbs for allocating buffers.