fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. const char *chyba_kpisz = "Chyba Kpisz";
  5.  
  6. int chyba_kpisz_rekurencyjnie(char c, int idx) {
  7. char *cptr = chyba_kpisz + idx;
  8. if (!*cptr) return -1;
  9. if (c == *cptr) return idx;
  10. return chyba_kpisz_rekurencyjnie(c, idx + 1);
  11. }
  12.  
  13. int main() {
  14.  
  15. printf("Index of 'C': %d\n", chyba_kpisz_rekurencyjnie('C', 0));
  16. printf("Index of 'K': %d\n", chyba_kpisz_rekurencyjnie('K', 0));
  17. printf("Index of 'X': %d\n", chyba_kpisz_rekurencyjnie('X', 0));
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 5508KB
stdin
Standard input is empty
stdout
Index of 'C': 0
Index of 'K': 6
Index of 'X': -1