Search
 
SCRIPT & CODE EXAMPLE
 

CPP

if vector contains value c++

#include <algorithm>

if(std::find(v.begin(), v.end(), x) != v.end()) {
    /* v contains x */
} else {
    /* v does not contain x */
}
Comment

check if an item is in a vector c++

bool Movies::add_movie(std::string name, std::string rating, int watched) {
    Movie pass(name,rating,watched);
    for(int i{0}; i < movies.size(); i++){
        if(movies.at(i).get_name() == name){
            return false;
        }
    }
    movies.push_back(pass);
    return true;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: sfml draw line 
Cpp :: std::pair c++ access element 
Cpp :: flutter margins 
Cpp :: cpp get data type 
Cpp :: min priority queue c++ 
Cpp :: c++ generate random char 
Cpp :: setprecision in c++ 
Cpp :: how to check datatype of a variable in c++ 
Cpp :: npm install error 
Cpp :: get current date in c++ 
Cpp :: for vector c++ 
Cpp :: colourful text in c++ 
Cpp :: struct and pointers (retun function) in c++ 
Cpp :: how to sort in descending order c++ 
Cpp :: repeat character n times c++ 
Cpp :: uri online judge 1930 solution in c++ 
Cpp :: C++ Third angle of a Triangle 
Cpp :: c++ files 
Cpp :: draw rect outline sdl2 
Cpp :: c++ loop programs 
Cpp :: add on screen debug message ue4 
Cpp :: print queue c++ 
Cpp :: Arduino Sring to const char 
Cpp :: how to hide ui elements unity 
Cpp :: c++ how to convert string to long long 
Cpp :: declare dynamic array c++ 
Cpp :: what is __asm in C++ 
Cpp :: in c++ ++ how to write if without if 
Cpp :: g++ optimization flags 
Cpp :: c++ program to take input from user 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =