Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! ![]()
Edit:
I can probably decipher enough of this to make a guess: replace all occurrences of
"0"
with
'0'
(the former is of type const char*; the latter is char. The type of s[someInt] is char, hence the error).
Edit2:
clang seems to be more helpful, here:
[simon@simon-laptop][18:22:39]
[~/devel/hackerrank/otherpeoples]>clang++ -std=c++14 bhavitjain11-LEBOMBS.cpp -O3 -g3 -Wall -Wextra
bhavitjain11-LEBOMBS.cpp:17:28: warning: result of comparison against a string literal is unspecified (use strncmp instead) [-Wstring-compare]
if(s[i]=="0" && s[i+1]=="0"){
^ ~~~
bhavitjain11-LEBOMBS.cpp:17:28: error: comparison between pointer and integer ('int' and 'const char *')
if(s[i]=="0" && s[i+1]=="0"){
~~~~^ ~~~
bhavitjain11-LEBOMBS.cpp:17:43: warning: result of comparison against a string literal is unspecified (use strncmp instead) [-Wstring-compare]
if(s[i]=="0" && s[i+1]=="0"){
^ ~~~
bhavitjain11-LEBOMBS.cpp:17:43: error: comparison between pointer and integer ('int' and 'const char *')
if(s[i]=="0" && s[i+1]=="0"){
~~~~~~^ ~~~
bhavitjain11-LEBOMBS.cpp:22:28: warning: result of comparison against a string literal is unspecified (use strncmp instead) [-Wstring-compare]
if(s[i]=="0" && s[i-1]=="0"){
^ ~~~
bhavitjain11-LEBOMBS.cpp:22:28: error: comparison between pointer and integer ('int' and 'const char *')
if(s[i]=="0" && s[i-1]=="0"){
~~~~^ ~~~
bhavitjain11-LEBOMBS.cpp:22:43: warning: result of comparison against a string literal is unspecified (use strncmp instead) [-Wstring-compare]
if(s[i]=="0" && s[i-1]=="0"){
^ ~~~
bhavitjain11-LEBOMBS.cpp:22:43: error: comparison between pointer and integer ('int' and 'const char *')
if(s[i]=="0" && s[i-1]=="0"){
~~~~~~^ ~~~
bhavitjain11-LEBOMBS.cpp:27:28: warning: result of comparison against a string literal is unspecified (use strncmp instead) [-Wstring-compare]
if(s[i]=="0" && s[i+1]=="0" && s[i-1]=="0"){
^ ~~~
bhavitjain11-LEBOMBS.cpp:27:28: error: comparison between pointer and integer ('int' and 'const char *')
if(s[i]=="0" && s[i+1]=="0" && s[i-1]=="0"){
~~~~^ ~~~
bhavitjain11-LEBOMBS.cpp:27:43: warning: result of comparison against a string literal is unspecified (use strncmp instead) [-Wstring-compare]
if(s[i]=="0" && s[i+1]=="0" && s[i-1]=="0"){
^ ~~~
bhavitjain11-LEBOMBS.cpp:27:43: error: comparison between pointer and integer ('int' and 'const char *')
if(s[i]=="0" && s[i+1]=="0" && s[i-1]=="0"){
~~~~~~^ ~~~
bhavitjain11-LEBOMBS.cpp:27:58: warning: result of comparison against a string literal is unspecified (use strncmp instead) [-Wstring-compare]
if(s[i]=="0" && s[i+1]=="0" && s[i-1]=="0"){
^ ~~~
bhavitjain11-LEBOMBS.cpp:27:58: error: comparison between pointer and integer ('int' and 'const char *')
if(s[i]=="0" && s[i+1]=="0" && s[i-1]=="0"){
~~~~~~^ ~~~
bhavitjain11-LEBOMBS.cpp:35:20: warning: result of comparison against a string literal is unspecified (use strncmp instead) [-Wstring-compare]
if(s[0]=="0"){
^ ~~~
bhavitjain11-LEBOMBS.cpp:35:20: error: comparison between pointer and integer ('int' and 'const char *')
if(s[0]=="0"){
~~~~^ ~~~
8 warnings and 8 errors generated.