Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Comparing user input to array characters

Comparing user input to array characters

Scheduled Pinned Locked Moved C#
tutorialcsharpdata-structureslearning
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neptune2k
    wrote on last edited by
    #1

    I have an array of letters which’s makes a word and I was wondering how I could compare a user’s input letter against the letters in the array so when running it would display something like this Example ** Word to be guessed in array – train ** User inputs letter a Displays _ _ a_ _ User inputs letter n Displays _ _ a _ n User inputs letter t Displays t _ a _ n And so on until the word is complete. If some1 could provide an example I could follow id be most grateful as I purchased a book a few days ago on c# programming and this is one of the tasks it doesn’t really give much info on how to do it. i know it uses a loop to move along and check each character but im not sure on this. thanks :)

    L L N 3 Replies Last reply
    0
    • N neptune2k

      I have an array of letters which’s makes a word and I was wondering how I could compare a user’s input letter against the letters in the array so when running it would display something like this Example ** Word to be guessed in array – train ** User inputs letter a Displays _ _ a_ _ User inputs letter n Displays _ _ a _ n User inputs letter t Displays t _ a _ n And so on until the word is complete. If some1 could provide an example I could follow id be most grateful as I purchased a book a few days ago on c# programming and this is one of the tasks it doesn’t really give much info on how to do it. i know it uses a loop to move along and check each character but im not sure on this. thanks :)

      L Offline
      L Offline
      lost in transition
      wrote on last edited by
      #2

      sound like hangman:rolleyes:

      Programmer: A biological machine designed to convert caffeine into code. * Developer: A person who develops working systems by writing and using software. [^]

      1 Reply Last reply
      0
      • N neptune2k

        I have an array of letters which’s makes a word and I was wondering how I could compare a user’s input letter against the letters in the array so when running it would display something like this Example ** Word to be guessed in array – train ** User inputs letter a Displays _ _ a_ _ User inputs letter n Displays _ _ a _ n User inputs letter t Displays t _ a _ n And so on until the word is complete. If some1 could provide an example I could follow id be most grateful as I purchased a book a few days ago on c# programming and this is one of the tasks it doesn’t really give much info on how to do it. i know it uses a loop to move along and check each character but im not sure on this. thanks :)

        N Offline
        N Offline
        neptune2k
        wrote on last edited by
        #3

        in a way yes, i guess it is the same principle, but i dont need to draw anything i think that is later on in the book, i have just been given a word in a string that i need to get the user to figure out, but its not very clear

        1 Reply Last reply
        0
        • N neptune2k

          I have an array of letters which’s makes a word and I was wondering how I could compare a user’s input letter against the letters in the array so when running it would display something like this Example ** Word to be guessed in array – train ** User inputs letter a Displays _ _ a_ _ User inputs letter n Displays _ _ a _ n User inputs letter t Displays t _ a _ n And so on until the word is complete. If some1 could provide an example I could follow id be most grateful as I purchased a book a few days ago on c# programming and this is one of the tasks it doesn’t really give much info on how to do it. i know it uses a loop to move along and check each character but im not sure on this. thanks :)

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          neptune2k wrote:

          I purchased a book a few days ago on c# programming

          It is a common misconception that learning to program is "equal" to learning a programming language. Evidence of it abounds here in these forums. Anyway, you need a book on Programming Logic and Design[^].

          led mike

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups