Problem with using readln.
JV via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Apr 29 20:18:39 PDT 2017
On Sunday, 30 April 2017 at 03:13:14 UTC, JV wrote:
> On Sunday, 30 April 2017 at 02:07:48 UTC, JV wrote:
>> Hello i'm kinda new to D language and i wanted to make a
>> simple program
>> but somehow my input does no go to my if statements and just
>> continues to ask for the user to input.Kindly help me
>>
>> btw here is my sample code
>>
>> int func;
>> writeln("\t\tEnter Selection : ");
>> func = readln();
>> writeln(func);
>>
>> if(func == 1)
>> {
>> writeln("hello world");
>> }
>> if(func == 2)
>> {
>> writeln("hello world");
>> }
>> if(func == 3)
>> {
>> writeln("endtime");
>> }
>> if(func == 4)
>> {
>> writeln("hello world");
>> }
>> if(func == 5)
>> {
>> writeln("hello world");
>> }
>
> I added the () at readln() got deleted when editing the code
> before i posted. sorry
On Sunday, 30 April 2017 at 03:13:14 UTC, JV wrote:
int func;
writeln("\t\tEnter Selection : ");
func = readln;
readln(func);
if(func == 1)
{
writeln("hello world");
}
if(func == 2)
{
writeln("hello world");
}
if(func == 3)
{
writeln("endtime");
}
if(func == 4)
{
writeln("hello world");
}
if(func == 5)
{
writeln("hello world");
}
else
{
display();
}
Mybad i posted the wrong one
More information about the Digitalmars-d-learn
mailing list