forked from menault/TD3_DEV51_Qualite_Algo
		
	ç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*/ | ||||
| 	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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user