ça marche
This commit is contained in:
17
getfuncs.c
17
getfuncs.c
@@ -34,9 +34,11 @@ int fetchWord(char* fullword, int file_length){
|
|||||||
/*variables*/
|
/*variables*/
|
||||||
FILE* stream;
|
FILE* stream;
|
||||||
int random = (rand() * time(NULL)) % (file_length);
|
int random = (rand() * time(NULL)) % (file_length);
|
||||||
char read[128];
|
char read[8];
|
||||||
unsigned int counter = 0;
|
unsigned int counter = 0;
|
||||||
int char_size = (int) sizeof(char);
|
int char_size = (int) sizeof(char);
|
||||||
|
int lign=0;
|
||||||
|
int offset=0;
|
||||||
|
|
||||||
/*prog*/
|
/*prog*/
|
||||||
printf("%d\n", random);
|
printf("%d\n", random);
|
||||||
@@ -45,11 +47,16 @@ int fetchWord(char* fullword, int file_length){
|
|||||||
return -1;
|
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'){
|
while(*read!='\n'){
|
||||||
fgets(read, sizeof(char), stream);
|
fread(read, sizeof(char), 1, stream);
|
||||||
printf("%c\n", *read);
|
|
||||||
fullword[counter] = *read;
|
fullword[counter] = *read;
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
@@ -66,7 +73,7 @@ int main(void){
|
|||||||
/*prog*/
|
/*prog*/
|
||||||
flength = getFileLength();
|
flength = getFileLength();
|
||||||
if(fetchWord(fullword, flength)!=-1){
|
if(fetchWord(fullword, flength)!=-1){
|
||||||
printf("test");
|
printf("%s", fullword);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|||||||
Reference in New Issue
Block a user