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 / C++ / MFC
  4. searching arrays

searching arrays

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomgame-devalgorithmsdata-structures
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.
  • I Offline
    I Offline
    InternetMill
    wrote on last edited by
    #1

    Hi all, I am working on a project for school(my final exam grade) and I have having a lot of trouble with it. We are making a hangman game and here is what I have to do. One user inputs the # of letters that the word will be and then enters those words into an array of CHAR's. Then a different user will take the seat and start guessing the letters. How do I search the first array and if a letter is right, fill the second array with the appropriate letter? Does this make any sense? Half my class doesn't get it and the teacher wasn't very helpful. An answer ASAP would be great as my exam is at 1:00 tomorrow. THanks Matt Matt Millican http://www.internetmill.com

    M B 2 Replies Last reply
    0
    • I InternetMill

      Hi all, I am working on a project for school(my final exam grade) and I have having a lot of trouble with it. We are making a hangman game and here is what I have to do. One user inputs the # of letters that the word will be and then enters those words into an array of CHAR's. Then a different user will take the seat and start guessing the letters. How do I search the first array and if a letter is right, fill the second array with the appropriate letter? Does this make any sense? Half my class doesn't get it and the teacher wasn't very helpful. An answer ASAP would be great as my exam is at 1:00 tomorrow. THanks Matt Matt Millican http://www.internetmill.com

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      Use strchr() to search a string for a particular character --Mike-- Latest blog entry: *drool* (Alyson) [May 10] Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber "You have Erica on the brain" - Jon Sagara to me

      1 Reply Last reply
      0
      • I InternetMill

        Hi all, I am working on a project for school(my final exam grade) and I have having a lot of trouble with it. We are making a hangman game and here is what I have to do. One user inputs the # of letters that the word will be and then enters those words into an array of CHAR's. Then a different user will take the seat and start guessing the letters. How do I search the first array and if a letter is right, fill the second array with the appropriate letter? Does this make any sense? Half my class doesn't get it and the teacher wasn't very helpful. An answer ASAP would be great as my exam is at 1:00 tomorrow. THanks Matt Matt Millican http://www.internetmill.com

        B Offline
        B Offline
        bond006
        wrote on last edited by
        #3

        I'm not sure if I understood you, but that's quite simple. An example: ------------------------------------------ #include #include #include void main() { char singleLetter; bool wordCompleted = false; unsigned int numOfLetters; unsigned int numOfGuessedLetters = 0; cout << "Number of letters: "; cin >> numOfLetters; char* pArray1 = new char[numOfLetters+1]; char* pArray2 = new char[numOfLetters+1]; memset(pArray2,'_',numOfLetters); pArray2[numOfLetters] = '\0'; cout << "Type in the word: "; cin >> pArray1; system("cls"); // Should the other player see what word we've typed in? ;) while(wordCompleted==false) { cout << "Type in a letter: "; cin >> singleLetter; for(unsigned int i=0;i

        I 1 Reply Last reply
        0
        • B bond006

          I'm not sure if I understood you, but that's quite simple. An example: ------------------------------------------ #include #include #include void main() { char singleLetter; bool wordCompleted = false; unsigned int numOfLetters; unsigned int numOfGuessedLetters = 0; cout << "Number of letters: "; cin >> numOfLetters; char* pArray1 = new char[numOfLetters+1]; char* pArray2 = new char[numOfLetters+1]; memset(pArray2,'_',numOfLetters); pArray2[numOfLetters] = '\0'; cout << "Type in the word: "; cin >> pArray1; system("cls"); // Should the other player see what word we've typed in? ;) while(wordCompleted==false) { cout << "Type in a letter: "; cin >> singleLetter; for(unsigned int i=0;i

          I Offline
          I Offline
          InternetMill
          wrote on last edited by
          #4

          Hi, I changed some stuff around that was incorrect, compiled it and all I got when I ran it was The very end of the program. Any other things? Matt Matt Millican http://www.internetmill.com

          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