readln() doesn't stop to read the input.
jonaspm via Digitalmars-d
digitalmars-d at puremagic.com
Fri Mar 27 20:07:29 PDT 2015
module main;
import std.stdio;
import std.string;
int main(string[] args)
{
int resp;
char[] p, q;
writefln("MENU DE OPCIONES");
writefln("1) Modus Ponens");
writefln("2) Modus Tollens");
writefln("3) Silogismo Hipotetico");
writefln("4) Salir");
do{
writeln("Introduce la opcion que deseas: ");
readf(" %d", &resp);
}while(resp<1 || resp>4);
write("Write p:");
readln(p); // This is skipped. ¿?
p = chomp(p);
write("Write q:");
readln(q);
q = chomp(q);
writeln("p: ",p); // Doesn't write anything.
writeln("q: ",q); // Writes what you typed in the keyboard
back on readln();
return 0;
}
This is the entire code.
Environment:
Windows 7 Home Premium x64
IDE: CodeBlocks 13.12
Compiler: Digital Mars D Compiler
More information about the Digitalmars-d
mailing list