Last active
May 8, 2021 14:47
-
-
Save mohamad-wael/797eca382fe64a32cb14eaf923b1f2ad to your computer and use it in GitHub Desktop.
How to use the tmpnam function in c ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int | |
main | |
(int argc , char * argv [ ] ){ | |
char tmp_path [L_tmpnam + 1 ]; | |
tmpnam (tmp_path ); | |
/*Generate a temp path .*/ | |
printf ("%s\n" , tmp_path ); | |
/* Output in Unix like OS : | |
/var/tmp/tmp.0.9oxTFK | |
Output in windows : | |
\s2ro. | |
Under windows \ indicates | |
that the name is valid under | |
the current working directory .*/ | |
char * tmp_path_1 = tmpnam (NULL ); | |
printf ("%s\n" , tmp_path_1 ); | |
/* Output in Unix like OS : | |
/var/tmp/tmp.1.Qo9D8Z | |
Output in windows : | |
\s3rg.1*/ | |
tmpnam (NULL ); | |
printf ("%s\n" , tmp_path_1 ); | |
/* Output in Unix Like OS : | |
/var/tmp/tmp.2.wnTK4D | |
Output in windows : | |
\s3rg.2 */ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment