It only returns the first line of the text file over and over again. Why?
Code:
//read a file.
FILE *t;
long lSize;
char * buffer;
char *l;
int i = 0;
//read a file.
t = fopen("test.txt","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) {
dccfsend(cSock,"%s\r\n",buffer);
l = strtok(NULL,"\r\n");
}
}
fclose(t);
free (buffer);
remove( "test.txt" );
} else dccfsend(cSock,"File Not Found: %s\r\n", arg);