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.

#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;
}

Well, this line doesn't make any sense:

list == argv[3];

Neither does this one:

cout << *list << endl;

Maybe you should explain what you think these lines are supposed to do, because it doesn't seem obvious to me (nor for the compiler). The variable list is a vector of strings, it doesn't make any sense to compare it to a string or to dereference and print it.

Yes an explaination might help every one. The idea was that list points to the contents of argv[3] (dictionary or text file) and then loop through it to see if there was a match with argv[2] (my mistake I typed argv[1]) and then output the word if there was a match.

This article has been dead for over six months. Start a new discussion instead.