ça marche

This commit is contained in:
vaisse
2025-10-08 12:35:01 +02:00
parent 0a7067acc3
commit 0908750892
2 changed files with 12 additions and 5 deletions

BIN
a.out Executable file

Binary file not shown.

View File

@@ -34,9 +34,11 @@ int fetchWord(char* fullword, int file_length){
/*variables*/
FILE* stream;
int random = (rand() * time(NULL)) % (file_length);
char read[128];
char read[8];
unsigned int counter = 0;
int char_size = (int) sizeof(char);
int lign=0;
int offset=0;
/*prog*/
printf("%d\n", random);
@@ -45,11 +47,16 @@ int fetchWord(char* fullword, int file_length){
return -1;
}
fseek(stream, random, 0); /*décalage*/
for(lign=0; lign<random; lign++){
while(*read!='\n'){
fread(read, sizeof(char), 1, stream);
offset++;
}
*read=' ';
}
while(*read!='\n'){
fgets(read, sizeof(char), stream);
printf("%c\n", *read);
fread(read, sizeof(char), 1, stream);
fullword[counter] = *read;
counter++;
}
@@ -66,7 +73,7 @@ int main(void){
/*prog*/
flength = getFileLength();
if(fetchWord(fullword, flength)!=-1){
printf("test");
printf("%s", fullword);
}
return EXIT_SUCCESS;