On 07/07/2012 03:35 PM, Mr. P-teo wrote:

> Basically whenever i use readf(); to gather console input it wont run
> the program if there is code afterwards.

readf() does not automatically consume the end-of-line character.

> That works fine, but if i try and imput 2 numbers to seperate variables
> it doesn't work.
>
>
> import std.stdio;
>
> int main(){
> long number, number2;
> write("Enter an integer: ");
> readf("%d", &number);

A space character in the format string reads and ignores any number of whitespace at that position.

> write("another no";
> readf("%d", &number2);
> return 0;

Just insert spaces before the format specifiers:

import std.stdio;

int main(){
    long number, number2;
    write("Enter an integer: ");
    readf(" %d", &number);
    write("another no");
    readf(" %d", &number2);

    writeln(number, ' ', number2);
    return 0;
}

Ali

--
D Programming Language Tutorial: http://ddili.org/ders/d.en/index.html

Reply via email to