Bonjour à tous, j'ai un petit problème lors de l'éxécution d'un programme ocaml : j'ai récupérer un bout de code d'un ami me permettant de récupérer le code hexadécimal d'une image, je l'ai compilé, et j'ai un exécutable. Le programme fonctionne parfaitement, mais à partir d'une certaine taille d'image le programme plante, en fait il s'arrête prématurément, et je ne récupère même pas un centième du code de l'image.
Voici le code :Pourriez vous m'indiquer pourquoi l'exécution stope ? Je me suis un peu renseigné, et c'est peut-être du à du "hard return", mais je n'ai pas trop compris à quoi cela correspondait. merci beaucoup !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 let hexa_from_int i = match i with |n when 10>n -> string_of_int n |10 -> "A" |11 -> "B" |12 -> "C" |13 -> "D" |14 -> "E" |15 -> "F" ;; let int_from_bin i = (i/16, i mod 16) ;; let hexa_from_bin i = let (a,b) = int_from_bin i in hexa_from_int a ^hexa_from_int b;; let tes = open_in Sys.argv.(1) ;; (*let rec string_from_channel chan = try match chan with |chan -> hexa_from_bin (input_byte chan)^(string_from_channel chan) with end_of_file -> "";;*) let string_from_channel chan = let str = ref "" in let boucle = try while true do str := (!str)^hexa_from_bin (input_byte chan) done; with end_of_file -> () in boucle; !str;; let test = string_from_channel tes;; let out = open_out "sortie.txt" ;; output_string out test;; close_out out;;
Partager