fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. void hoge(const char *p)
  5. {
  6. size_t i;
  7.  
  8. for (i = strlen(p) - 1; i != (size_t)-1; i--) {
  9. if (p[i] == '.') break;
  10. }
  11. printf("%s=%d\n", p, i);
  12. }
  13.  
  14. int main()
  15. {
  16. hoge("a.c");
  17. hoge("abc");
  18. hoge("");
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
a.c=1
abc=-1
=-1