468,484 Members | 1,973 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

get temp directory

How to get user temporany directory from c++ function?

example:

string myTempDir = getTempDir();

now myTempDir contains 'c:\tmp'

is there a portable function?
Feb 28 '08 #1
3 5084
Alberto Bignotti wrote:
How to get user temporany directory from c++ function?

example:

string myTempDir = getTempDir();

now myTempDir contains 'c:\tmp'

is there a portable function?
No, there is no portable function because there is no portable
notion of "user temporary directory". However, you could try
'getenv("TEMP")' or 'getenv("TMP")'. RTFM about it.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Feb 28 '08 #2
On Feb 28, 4:00 pm, "Alberto Bignotti" <a.bigno...@abacogroup.com>
wrote:
How to get user temporany directory from c++ function?

example:

string myTempDir = getTempDir();

now myTempDir contains 'c:\tmp'

is there a portable function?
Alberto,

As Victor says c++ has no notion of a temporary file directory, but if
you just want to create a temporary file the the C library's stdio
header provides the function tmpfile():
http://www.cplusplus.com/reference/c...o/tmpfile.html

HTH,
--rob
Feb 28 '08 #3
On Feb 28, 5:03 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Alberto Bignotti wrote:
How to get user temporany directory from c++ function?
example:
string myTempDir = getTempDir();
now myTempDir contains 'c:\tmp'
is there a portable function?
No, there is no portable function because there is no portable
notion of "user temporary directory". However, you could try
'getenv("TEMP")' or 'getenv("TMP")'. RTFM about it.
TMPDIR is what Posix recommends, I think.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Feb 28 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Adam Parkin | last post: by
1 post views Thread by john bailo | last post: by
reply views Thread by Matthew Fitzpatrick | last post: by
5 posts views Thread by Patrick | last post: by
2 posts views Thread by Lars Netzel | last post: by
6 posts views Thread by Najd | last post: by
6 posts views Thread by Aussie Rules | last post: by
reply views Thread by NPC403 | last post: by
2 posts views Thread by gieforce | last post: by
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.