I am trying to convert III
stored in string s
in Roman numerals to 3. Here is a code snippet:
int i = 0;
int num = 0;
while (i < s.size()){
if (strcmp(s[i], "I") == 0){
num = num + 1;
i = i + 1;
}
else{
continue;
}
}
return num;
I am facing issues with using the strcmp()
function. How can I use it successfully?
Here is the error:
Line 18: Char 17: error: no matching function for call to 'strcmp'
if (strcmp(s[i], "I") == 0){
^~~~~~
/usr/include/string.h:137:12: note: candidate function not viable: no known conversion
from '__gnu_cxx::__alloc_traits<std::allocator<char>,
char>::value_type' (aka 'char') to 'const char *' for 1st argument;
take the address of the argument with &
extern int strcmp (const char *__s1, const char *__s2)
^