Please Help!!!
My understanding of getopt is very limited.
I do however realise that argv[0] is the exe file, argv[1] is the option, argv[2] is the word to compare and argv[3] is the dictionary or document I want to search(file .txt).
I'm trying to set a pointer to the dictionary and then iterate through it to see if there is a match with the argv[2] (input word) to the text file, and if there is a match out put the argv[2] word.
Below is my current code that has errors
main.cpp:61: error: no match for 'operator==' in 'list == *(argv + 12u)'
main.cpp:64: error: no match for 'operator*' in '*list'
Any help would be greatly appreciated.
Code:#include <cstdlib> #include <unistd.h> #include <vector> #include <iostream> #include <string> #include <iterator> using namespace std; int main(int argc, char** argv) { enum { WHOLE, PREFIX, SUFFIX, ANYWHERE, EMBEDDED } mode = WHOLE; bool jumble = false; bool ignore_case = false; bool invert = false; string length = "0,0"; int c; string input; vector <string> list; vector <string>::iterator i; while ((c = getopt(argc, argv, ":wpsaejivn:")) != -1) { switch (c) { case 'w': mode = WHOLE; break; case 'p': mode = PREFIX; break; case 's': mode = SUFFIX; break; case 'a': mode = ANYWHERE; break; case 'e': mode = EMBEDDED; break; case 'j': jumble = true; break; case 'i': ignore_case = true; break; case 'v': invert = true; break; case 'n': length = optarg; break; default: WHOLE; break; } } argc -= optind; argv += optind; switch (mode) { case WHOLE: while(argc != -1){ list == argv[3]; for(i == list.begin(); i != list.end(); i++) if(argv[1] == argv[3]){ cout << *list << endl; }else cout << "Did not work again" << endl; } } return 0; }



LinkBack URL
About LinkBacks


