I've been working on a method which is supposed to convert a Pascal string to a C String. I was also told that the char * returned should point to a newly allocated char array containing a null-terminated C-String. The callee is responsible for calling free() on this array.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char *pascal_convert(void *x)
{
int *y;
x = y;
char *z;
*z = *((int*)x);
char *arr = malloc(sizeof(*z));
for (int i = 0; i < *y; i++)
{
arr[i] = z[i];
}
char* fin = arr;
return fin;
}
pascal_convert? Did you test it?free().