This commit is contained in:
vaisse
2025-10-08 14:19:47 +02:00
parent 0908750892
commit ff97710546
2 changed files with 13 additions and 13 deletions

BIN
a.out

Binary file not shown.

View File

@@ -8,9 +8,9 @@
int getFileLength(){ int getFileLength(){
/*variables*/ /*variables*/
FILE* stream; FILE* stream;
int length = 0; int file_length = 0;
char* line = NULL; char* line = NULL;
size_t len = 0; size_t length = 0;
ssize_t read; ssize_t read;
/*prog*/ /*prog*/
@@ -19,12 +19,12 @@ int getFileLength(){
return EXIT_FAILURE; return EXIT_FAILURE;
} }
while((read = getline(&line, &len, stream)) != -1){ while((read = getline(&line, &length, stream)) != -1){
length++; file_length++;
} }
fclose(stream); fclose(stream);
return length-1; return file_length-1;
} }
/* /*
@@ -37,7 +37,7 @@ int fetchWord(char* fullword, int file_length){
char read[8]; 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 line=0;
int offset=0; int offset=0;
/*prog*/ /*prog*/
@@ -47,14 +47,15 @@ int fetchWord(char* fullword, int file_length){
return -1; return -1;
} }
for(lign=0; lign<random; lign++){ while((!feof(stream))&&(offset!=random)){
while(*read!='\n'){
fread(read, sizeof(char), 1, stream); fread(read, sizeof(char), 1, stream);
if(*read=='\n'){
offset++; offset++;
} }
*read=' ';
} }
*read=' ';
while(*read!='\n'){ while(*read!='\n'){
fread(read, sizeof(char), 1, stream); fread(read, sizeof(char), 1, stream);
fullword[counter] = *read; fullword[counter] = *read;
@@ -65,16 +66,15 @@ int fetchWord(char* fullword, int file_length){
return 0; return 0;
} }
/*
int main(void){ int main(void){
/*variables*/
int flength; int flength;
char fullword[128]; char fullword[128];
/*prog*/
flength = getFileLength(); flength = getFileLength();
if(fetchWord(fullword, flength)!=-1){ if(fetchWord(fullword, flength)!=-1){
printf("%s", fullword); printf("%s", fullword);
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }*/