fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int count(char* str,char chr)
  5. {
  6. if (*str==0)
  7. return 0;
  8. if(*str==chr)
  9. return 1+count(str+1,chr);
  10. else
  11. return 0+count(str+1,chr);
  12. }
  13. int main() {
  14. char a='12345';
  15. char b='1';
  16. cout<<count(a,b);
  17. // your code goes here
  18. return 0;
  19. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:14:9: warning: character constant too long for its type
  char a='12345';
         ^
prog.cpp: In function 'int main()':
prog.cpp:14:9: warning: overflow in implicit constant conversion [-Woverflow]
prog.cpp:16:17: error: invalid conversion from 'char' to 'char*' [-fpermissive]
  cout<<count(a,b);
                 ^
prog.cpp:4:5: note: initializing argument 1 of 'int count(char*, char)'
 int count(char* str,char chr)
     ^
stdout
Standard output is empty