2
magis
8y

Any c++ Gods able to offer a bit of help? I can't ask on stack for risk of a lecturer finding out but I really need help...

Comments
  • 0
    I'm no where near a god, but I might be able to help
  • 0
    @Cruiser thank you! Basically I have a function that compares two character arrays to find words (since words can be within words, like bullshit and I need to remove the shit, so I can't just compare words) i have

    If( fileToSearch[i] == searchWord[0])
    If( fileToSearch[i + 1] == searchWord[1])
    If( fileToSearch[i + 2] == searchWord[2])

    Then replace the characters of file to search with !

    But it needs simplifying, and since all searchWords have a different length I can't have this mess of if statements, but I can't figure out a way to simplify it
  • 0
    @magis this actually sounds like a great use for regular expressions. i would think about making the search word your regex and use regex _match. you can #include <regex> to use it, and a great site for learning regex in general is regexr.com
  • 0
    i would use regex - however im not c++ im c# but im guessing the implimentation would be the same. but it looks as if it would fit the need.

    are you wanting to detect how close the two words are or just detect there the same
  • 0
    also you would need a libary of words to compare against if im reading this right your trying to find words from taking each character and finding words you would need a word repository am i wrong?
  • 0
    @wildgoosecsharp my word repos come from my two char arrays! I'm having a quick learn of regex now, seemingly impossible task haha but giving it a go, cheers guys
  • 0
    i added regex into my plagurism script for my disertation and it near about murdered me lol.

    just add wildcards between places you dont know whats there and monitor what it picks up
Add Comment