Hello
I have this code:
It is working just fine with fprintf , i want to print it character by character .. but it is giving me An error has occured : Bad file discriptorCode:void prtastr(const char *buf, int fd,int n){ int i,err; char* s; if ((s=calloc(strlen(buf)+1,sizeof (char)))==NULL) perror("couldn't copy buffer"); strcpy(s,buf); //fprintf(stderr,s); while (s!=NULL){ while(((err=write(fd,s,1))==-1)&&(errno==EINTR)); if(err==-1)perror("An error has occured"); s++; } }
I don't know what is wrong with my file discriptor i am calling it using :
(int) stderr
All help are apreciated



LinkBack URL
About LinkBacks


