You could stick a Module-version of the function below in your T module:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *repeat (int count, const char *a)
{
while(count > 0) {
count--;
}
return strtmp;
}
int main(int argc, char const *argv[])
{
printf("%s\n",repeat
(3,"ABC")); return 0;
}
Yes, I know it's leaking for each call to the function because the caller (main, in this case) is not freeing the return value. But for a trivial example like this, I wanted to show how this could be done.
It's important that the strtmp variable is large enough to hold the result of the strcat loop, which is why there's a calculation performed.
Broken down, if we use the second printf statement as an example, the function allocates 3*the size of the source + 1, in this case (3*3)+1 = 10, which is the length of ABCABCABC plus room for a terminating '\0'. [Operator precedence causes the multiplication to happen first (count*strlen(a)) and then the addition of '1' to occur.]
AIR.