Ad
  • Custom User Avatar

    asprintf() is a Linux function, not in standard C or POSIX. you must either declare it manually, or #define _GNU_SOURCE before you #include <stdio.h>

  • Custom User Avatar

    The tests free it. It's always the case when you must return a heap allocated array / string (you cannot free it yourself: where would you? After return, the statement is not executed, before return then you would return a pointer to something not allocated anymore).

  • Custom User Avatar

    Why is the memory pointed to by r not released at the end of the function

  • Custom User Avatar

    Nice! something to consider would be scanning the two arrays separately first to find the shortest and longest string, and then doing the comparison after.