fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int main(void) {
  6.  
  7. char values[] = "/home/user/desktop/foo.pem";
  8. char find = ';';
  9.  
  10. const char *ptr = strrchr(values, find);
  11. int index = 0;
  12. if(ptr) {
  13. index = ptr - values;
  14. // do somethin
  15. printf("index: %d\n", index);
  16. }
  17. char *base = malloc(index + 10);
  18. memcpy(base, values, index);
  19. printf("base: %s\n", base);
  20. strcat(base, "-cert.pub");
  21. printf("base: %s\n", base);
  22.  
  23. // your code goes here
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
base: 
base: -cert.pub