I'm having trouble creating a main so I can test if my function is working well. My program is as follows: LInt fromArray (int v [], int N) which, given an array v with N elements, sorted in ascending order, builds an ordered list with array elements, in the same order. Here's what I was able to 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 main?