First of all your functions have no return type. Though old C compilers allow to do this defining implicitly the return type as int
I advice to specify explicitly the return type of a function.
As for your errors then you shall not use the dereference operator in expressions as you do
* head = * head -> next;
or
* head -> next = temp2;
It would be correct to write
*head = ( *head )->next;
and
(*head )->next = temp2;
Though semantically this code is invalid. You are changing head in the loop while it shall not be changed.
Also function insert_Nth_position is wrong. Imagine for example that the value of parameter int posn
is equal to 0. In this case condition while (count != posn - 1);
will be invalid.
I would define the parameter that specifiers the position in the list as having type unsigned int
or size_t
Function insert_Nth_position could look the following way
int insert_Nth_position( node ** head, size_t posn, int varn )
{
if ( posn == 0 ) return insert_beginning( head, varn );
node *tmp = *head;
while ( --posn && tmp ) tmp = tmp->next;
if ( tmp )
{
node *new_node = malloc( sizeof( node ) );
new_node->freq = varn;
new_node->next = tmp->next;
tmp->next = new_node;
}
return ( temp != NULL );
}
If your compiler supports C99 then the return type could be substituted for _Bool
Also function insert_beginning I would declare as
int insert_beginning( node ** head, int varn );