![]() |
| | #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;
}
|
| steals10304 is offline | |
| | #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 | |
| | #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 | |
![]() |
| Thread Tools | |
| Display Modes | |
|
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 |