Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

question on user input

user input

  • Please log in to reply
17 replies to this topic

#13 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 21 September 2008 - 12:32 PM

Um:

while (input != 1 && input != 2 && input != 3 && input != 4)

I think you got something wrong there? So the loop runs while

input isn't 1 and input isn't 2 and input isn't 3 and input isn't 4? That doesn't make much sense. ?
  • 0

#14 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 21 September 2008 - 12:34 PM

It runs whilst the loop is anything other than 1, 2, 3 or 4.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#15 John

John

    CC Mentor

  • Moderator
  • 4450 posts
  • Location:New York, NY

Posted 21 September 2008 - 12:38 PM

Shh, my dear John. :)

I don't think anyone else has actually memorised the different codes for regexes.


No one needs to memorize them. They can reference my cheat sheet. :)
  • 0

#16 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 21 September 2008 - 12:39 PM

Er, ok I made a stupid comment. :D

Yeah, just use John's cheat sheet, or memorize them. :P I would just use the cheat sheet though.
  • 0

#17 Rechocto

Rechocto

    CC Newcomer

  • Just Joined
  • PipPip
  • 13 posts

Posted 24 September 2008 - 08:37 AM

int input = 0;
getinput:
Console.WriteLine("1: North\r\n2: East\r\n3: South\r\n4: West");
input = int.Parse(Console.ReadLine());
if(input < 1 || input > 4) goto getinput;
  • 0

#18 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 26 September 2008 - 07:53 AM

Please use [NOPARSE][/NOPARSE] tags.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?





Also tagged with one or more of these keywords: user input

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download