peri mkstemp
Michalis Kabrianis
kabrianis at hellug.gr
Sun Feb 7 19:47:25 EET 1999
Sorry, alla egw blepw 2 lathi:
On 07-Feb-99 D.A.Glynos wrote:
> re gmt giati to parakatw den douleuei?
> Egrapsa 5-6 grammes kwdika gia na ftiaxnei ena temporary file :
>
>#include <unistd.h>
>#include <stdio.h>
>#include <stdlib.h>
>#include <sys/stat.h>
>
> main(){
> int fd;
> char *k;
>
> k= (char *) malloc(sizeof(k));
> k="/ergasia/temp/koukouXXXXXX";
Se strings to = den ginetai (se apli C) ap' oti kserw, ara prepei na
xrisimopoiiseis to strcpy. P.x.
strcpy(k,"/ergasia/temp/koukouXXXXXX");
Akoma kalytera, apofeygeis kai to malloc me tin strdup:
strdup(k,"/ergasia/temp/koukouXXXXXX");
> umask(022);
> fd=mkstemp(k);
> write(fd,"patates",sizeof("patates"));
To sizeof("patates") den exei orisma bebaia. Ayto pou theleis einai ena strlen
strlen("patates")+1 Edw nomizw oti xreiazetai kai to +1 gia to NULL, alla den
eimai sigouros. As mas to dieykrinisei kapoios :-)
> close(fd);
> printf("%i",fd);
> free(k);
> }
>
> Euxaristw ek twn proterwn
> dimitris
Me aytes tis allages mou doulevei. Min ksexaseis na symperilabeis (include) tin
string.h
Michalis Kabrianis
kabrianis at hellug.gr
--
====================================================================
Gia boithia (h na diagrafhte) e-mail sto majordomo at hellug.gr
Ta archives tis listas einai sto http://lists.hellug.gr
prin steilete kapoia erothsh psakte mipos exei hdh apanththei.
Gia opoiodipote problima stilte e-mail ston owner-linux-greek-users
====================================================================
More information about the Linux-greek-users
mailing list