fork(2) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. char *substring(char *str, char *buf, int start, int end) {
  5. for (int i = start; i < end; i++)
  6. buf[i] = str[i];
  7. return buf;
  8. }
  9.  
  10. int main() {
  11. char *texto = malloc(6);
  12. if (strncmp(substring("Hello World", texto, 0, 5), "Hello", 5) == 0)
  13. printf("yep");
  14. free(texto);
  15. return 0;
  16. }
Success #stdin #stdout 0s 2288KB
stdin
Standard input is empty
stdout
yep