Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug dans l'entrée interactive sous windows #8002

Closed
vicuna opened this issue Jan 31, 2003 · 1 comment
Closed

Bug dans l'entrée interactive sous windows #8002

vicuna opened this issue Jan 31, 2003 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jan 31, 2003

Original bug ID: 1530
Reporter: administrator
Status: closed
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Bonjour,

Un petit exercice sous OcamlWin et Emacs a mis en évidence un problème
lié aux entrées sorties sous Windows.
Le programme suivant demande de saisir un nombre au clavier puis
l'affiche après l'avoir divisé par 10 :

let main () =
Printf.printf "Entrez un nombre : ";
let s = read_line () in
Printf.printf "Vous avez entré : "%s"" s;
Printf.printf "Divisé par 10 : %d" (int_of_string s / 10)
;;
main ();;

Ce programme fonctionne parfaitement compilé avec ocamlc ou ocamlopt ou
en mode interactif sous DOS, mais sous OcamlWin et Emacs on obtient
généralement :

#use "C:/hello.ml";;

val main : unit -> unit =
Entrez un nombre : 200
Vous avez entré : "Entrez un nombre : 200"
Exception: Failure "int_of_string".

Que vient faire "Entrez un nombre : " dans la chaîne saisie ?

La version utilisant le module Scanf (après avoir compilé scanf.ml dans
la librairie standard car ce n'est pas fait par défaut) plante aussi
(sous OcamlWin et Emacs, pas sous DOS) :

#use "C:/hello.ml";;

val main : unit -> unit =
Entrez un nombre : 200
Exception: Failure "int_of_string".

Fichier hello.ml :

let main () =
Printf.printf "Entrez un nombre : ";
flush stdout;
let n = Scanf.scanf "%s" int_of_string in
Printf.printf "Vous avez entré : %d\n" n;
Printf.printf "Divisé par 10 : %d" (n / 10)
;;
main ();;

Cordialement,

Sébastien Furic.

@vicuna
Copy link
Author

vicuna commented Jul 3, 2004

Comment author: administrator

Both Emacs and OCamlWin send the whole line where the cursor is. This cannot
be
changed under Emacs, and probably will not be changed under OCamlWin anytime
soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant