Bonjour,
Je débute le CPP et je bloque sur quelque chose que je ne comprends pas.
J'ai une fonction qui récupère un vector<string> name, et je cherche un élément dedans donc je dois me déplacer à l'intérieur de mon vector. Pour ce faire j'utilise un index et j'incrémente mon vector de façon à me déplacer string par string :
Cependant à la compilation j'obtiens :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 std::string Parser::findMeta(std::vector<std::string> array) { int i = 0; while (array[i]) { if (array[i].find("meta-charset")) return ("OK"); i++; } return ("NOO"); }
Auriez-vous une solution?/home/untitled/parser.cpp:36: erreur : could not convert ‘array.std::vector<_Tp, _Alloc>::operator[]<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >(((std::vector<std::__cxx11::basic_string<char> >::size_type)i))’ from ‘__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> > >::value_type {aka std::__cxx11::basic_string<char>}’ to ‘bool’
while (array[i])
^
Merci
Partager