xiluoc un pc pour les unirs .... | Code :
- void gettext(FILE *send, FILE *read, char *string)
- {
-
- long lSize;
- char * buffer;
- int length;
- char command[128]="GETTEXT ";
- strcat (command,string);
- length = strlen(command);
- command[length] = 0xff;
-
- fprintf(send,"%s",command);
- fflush(send);
- if (read==NULL) { printf("opening failed\n" ); exit (1);}
- // obtain file size.
- fseek (read , 0 , SEEK_END);
- lSize = ftell (read);
- printf("%d",lSize);
- rewind (read);
- // allocate memory to contain the whole file.
- buffer = (char*) malloc (lSize);
- if (buffer == NULL) { printf("error buffer empty\n" ); exit (2);}
- // copy the file into the buffer.
- fread (buffer,1,lSize,read);
- printf(buffer);
- free (buffer);
- //while ((c = fgetc(read)) != EOF) { putchar(c); }
- //printf("\n" );
- }
|
read n'est pas vide, vu que //while ((c = fgetc(read)) != EOF) { putchar(c); }
//printf("\n" );
renvoie tout le text.
fseek (read , 0 , SEEK_END); renvoie -1
|