1
I’m having a hard time creating a main to test if my function is going well. My program is as follows: : Lint fromArray (int v[], int N) which, given an array v with N elements, ordered in ascending order, constructs an ordered list of the array elements in the same order. Here’s what I could do :
typedef struct slist
{
int valor;
struct slist *prox;
} *LInt;
LInt fromArray (int v[], int N)
{
LInt nova = (LInt)malloc(sizeof (struct slist));
LInt aponta = nova;
int i;
if (N==0)
{ return NULL; }
for (i = 0 ; i < N ; i++)
{
nova->valor = v[i];
nova->prox = (LInt)malloc(sizeof (struct slist));
nova = nova->prox;
}
nova = NULL;
return aponta;
}
How do I main for this function ? And in general for functions on linked lists , what is the main aspect to take into account when creating the main?