Finding a string input in a 2D char array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Spooner
    New Member
    • Oct 2006
    • 7

    Finding a string input in a 2D char array

    I have code that reads in a paragraph of words from a .txt file. How would I go about finding a string that a user inputs into the program? I read in the text as a char, so perhaps I should change the user input into a string?

    Any ideas would be appreciated.
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    Originally posted by Spooner
    I have code that reads in a paragraph of words from a .txt file. How would I go about finding a string that a user inputs into the program? I read in the text as a char, so perhaps I should change the user input into a string?

    Any ideas would be appreciated.
    if you are using C++ you could read the text into a string which you put in a vector. you can search the vector using an iterator

    Comment

    • Spooner
      New Member
      • Oct 2006
      • 7

      #3
      Originally posted by horace1
      if you are using C++ you could read the text into a string which you put in a vector. you can search the vector using an iterator
      Okay, I did all that, now I'm using the find() function for iterator. I also want to make a count of how many of word are there in the text. I have a count variable set up, but how would I change the index of the find function? I did the line.begin() to start it off.

      Comment

      Working...