Yes it solved my problem... Actually, vista is installed on D drive which is root directory on my PC. Previously, I use to log on as a user who was not having write/ create file permission on root directory. That is the reason why tmpfile() was returning NULL. The temporary file is created when I log on as an Administrator or a user who has that permission. I gave Permission "Full Control" to User. I solved that my "right clicking on D drive", then "propertise", then going to "Security Tab", then "Advanced", and then "selecting the User" and then "Edit" and giving the appropriate permission. Thanks & Regards, Sameer.