Code giving segmentation fault
in line no 22
codtion is wrong if element present you add true with it
but if not present then you don’t assign false
so correct condition is
if(it!=m.end()){
}
this because map: find(k)
Searches the container for an element with a key equivalent to k and returns an iterator to it if found, otherwise it returns an iterator to map::end
and if you want to use stl then there is no point of making map
same thing you can do with array
you can find element in array as well
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.