I have a problem with reading files.
I use this code to read a file:
OK works fine for Text files, but binary files such as exe Files have characters that break the loop an I only get a little big of the real file.Code:FILE *t; long lSize; char * buffer; char *l; //read a file. t = fopen(arg,"rb"); if (t!=NULL) { fseek (t , 0 , SEEK_END); lSize = ftell (t); rewind (t); buffer = (char*) malloc (lSize); fread (buffer,1,lSize,t); l = strtok(buffer,"\r\n"); while(l != NULL) { if (strlen(l)>0) { safeircfsend("PRIVMSG %s :%s\r\n",nick, l); } l = strtok(NULL,"\r\n"); } fclose(t); free (buffer);
I need a function which definatly read the whole file and give me the output.
Any ideas?



LinkBack URL
About LinkBacks


