C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-07-2009, 12:14 AM   #1
Registered User
 
Join Date: Aug 2009
Posts: 30
Why is tmpfile returning my stderr message?

Code:
FILE *OpenTemporaryFile(void)
{
  FILE *pFile;
  if((pFile = tmpfile()) == NULL)
  {
     fprintf(stderr, "Cant open temp file\n");
     exit(EXIT_FAILURE);
  }
  return pFile;
}
I'm a novice coder, but I'm pretty sure I've coded this correctly? Help?
steals10304 is offline   Reply With Quote
Old 11-07-2009, 12:20 AM   #2
Registered User
 
Join Date: Oct 2006
Location: Canada
Posts: 848
Seems to work fine for me. Can you try to re-compile and run it again?
nadroj is offline   Reply With Quote
Old 11-07-2009, 03:50 AM   #3
Registered User
 
Join Date: Jun 2005
Posts: 1,343
tmpfile() is presumably failing on your system. The reasons vary between systems (eg with operating system, compiler/library, and resources available on your system).

A common reason for failure is that files cannot be created in the current working directory. Reasons that might occur vary, but include a working directory that does not exist, a working directory on a hard drive with no spare space, and things like that.

Another common reason is that your program already has several file handles already open, sufficient that some quota (eg set by an administrator, or a default operating system limit) is exceeded.

Without information on the code that is calling your function, or the system on which your program is running, it is not possible to give a more specific response.
__________________
Right 98% of the time, and don't care about the other 3%.
grumpy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Message loop? Shadowwoelf Windows Programming 2 07-21-2007 09:58 PM
Please Help - Problem with Compilers toonlover C++ Programming 5 07-23-2005 10:03 AM
fprintf to stderr crash programs jlai Windows Programming 2 04-12-2005 08:51 AM
input/output dogbert234 Windows Programming 11 01-26-2005 06:57 AM
Tab Controls - API -KEN- Windows Programming 7 06-02-2002 09:44 AM


All times are GMT -6. The time now is 02:06 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22