I'm a beginner and getting back to programming after 2 months. Almost forgotten everything. The code I just tried to compile eliminates the second half of the vector usin iterators, if the character I want is found in the first half.
Here's the code:
#include<iostream> #include<string> #include<vector> using namespace std; int main() { vector<string> v; string s("hello world"); char sought = 'e'; v.push_back(s); auto mid = (v.begin() + v.end())/2; if (sought<*mid) { end = mid; } cout<<*v; } Please tell me what my mistake is.
Also, can programming be forgotten? Also, once proficient, do the concept stay forever, or does it require constant practice and reading?
end/itcome from?itorend. Correct your basic errors before asking about the algorithm.cout<<*v;this is not valid,sought<*midwon't compile as well.