Hi,
I just tried your code with Open Watcom, ( my preferred compiler ), and it gave me numerous warings! As advised, your malloc etc is wrong for the context you want.
I chaged it to give a file size and lo and behold - no probs.
Often we see people using 'compilers' like VC++ Epresss and the others. Why not use a 'real' compiler. Watcom is free, ( and has everything for Microsoft users ). Lets face it, if you're going to write serious sofware then you need to use professional tools.
Very good Lamblion - tonight I can't see the wood for the trees again!
I was was going to ask you for a discussion sometime but I'm exhausted tonight and that bit of grey matter that I might have left, well its gone - so I'm off to bed - Goodnight.