hey guys,
Do you know how to search the array for the word (string type) and if the word does not exist in the array, add it to the array?
I did something like this (see code below), but I fear that for every value in the arraythat is not equal to the word, the same word will be added as many times as the total numbers of values in the array. I need to add only ONE value if none of other values in the array are the same as the value I want to add to array.
Wrong code:
Your input will be greatly appreciated!Code:#include"lvp/vector.h" #include<string.h> ... vector<string>col2; for(int k=0; k<col2.length(); k++) { if(col2[k]!=word) { col2.resize(col2.length()+1); col2[b]=word; b++; } }
thanks,