@rubberman , you mean like this:

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

//(*******************************************************************************)
void addNulls(char L[][9], int N[], int M[])
{
    int i,j,g;

    for (i=1 ; i<9 ; i++)
    {
        for (j=1 ; j<9 ; j++)
        {
            if (L[i][j]!='K')
            {
                L[i][j]='0';
            }
        }
    }
    for (i=1 ; i <9 ; i++)
    {
        for (j=1 ; j <9; j++)
        {
            if (L[i][j]=='K')
            {
                for (g=1 ; g <10; g++)
                {
                    if (i+N[g]>0&&i+N[g]<9 && j+M[g]>0 && j+M[g]<9 && L[i+N[g]][ j+M[g]] == '0')
                    {
                        L[i+N[g]][ j+M[g]] = '*';
                    }
                }
            }
        }
    }
}
//(*******************************************************************************)
bool checkIf(char L[][9], int N[], int M[])
{
    int i, j;

    for ( i=1 ; i<9; i++)
    {
        for (j=1 ; j <9; j++)
        {
            if (L[i][j]=='K')
            {
                if (i-2>0)
                {
                    if (j-1>0 && L[i-2][j-1]=='0')
                    {
                        L[i-2][j-1]='*';
                    }
                    if (j+1<9 && L[i-2][j+1]=='0')
                    {

                        L[i-2][j+1]='*';
                    }
                    if (j-2>0 && L[i-1][j-2]=='0')
                    {
                        L[i-1][j-2]='*';
                    }
                    if (j+2<9 && L[i-1][j+2]=='0')
                    {
                        L[i-1][j+2]='*';
                    }
                }
                else if (i-1>0)
                {
                    if (j-2>0 && L[i-1][j-2]=='0')
                    {
                        L[i-1][j-2]='*';
                    }
                    if (j+2<9 && L[i-1][j+2]=='0')
                    {
                        L[i-1][j+2]='*';
                    }
                }
                if (i+2<9)
                {
                    if (j-1>0 && L[i+2][j-1]=='0')
                    {
                        L[i+2][j-1]='*';
                    }
                    if (j+1<9 && L[i+2][j+1]=='0')
                    {
                        L[i+2][j+1]='*';
                    }
                    if (j-2>0 && L[i+1][j-2]=='0')
                    {
                        L[i+1][j-2]='*';
                    }
                    if (j+2<9 && L[i+1][j+2]=='0')
                    {
                        L[i+1][j+2]='*';
                    }
                    // return true;
                }
                else if (i+1<9)
                {
                    if (j-2>0 && L[i+1][j-2]=='0')
                    {
                        L[i+1][j-2]='*';
                    }
                    if (j+2<9 && L[i+1][j+2]=='0')
                    {
                        L[i+1][j+2]='*';
                    }
                }

            }

        }
        //return true;
    }
    int cnt=0;
    for( i=1 ; i<9; i++)
    {
        for (j=1 ; j<9; j++)
        {

            if (L[i][j]=='0')
            {
                cnt++;
            }

        } ...

Hi, I am making program that finds solution how to put 12 knights(horses) to chess board that every square is dominated or engaged by other knight.
Look at my code:

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

//(*******************************************************************************)
void addNulls(char L[][9], int N[], int M[])
{
    int i,j,g;

    for (i=1 ; i<9 ; i++)
        for (j=1 ; j<9 ; j++)
            if (L[i][j]!='K')
                L[i][j]='0';
    for (i=1 ; i <9 ; i++)
        for (j=1 ; j <9; j++)
            if (L[i][j]=='K')
                for (g=1 ; g <9; g++)
                    if (i+N[g]>0&&i+N[g]<9 && j+M[g]>0 && j+M[g]<9 && L[i+N[g]][ j+M[g]] == '0')
                        L[i+N[g]][ j+M[g]] = '*';
}
//(*******************************************************************************)
bool checkIf(char L[][9], int N[], int M[])
{
    int i, j;

    for ( i=1 ; i<9; i++)
        for (j=1 ; j <9; j++)
            if (L[i][j]=='K')
            {
                if (i-2>0)
                {
                    if (j-1>0 && L[i-2][j-1]=='0')
                        L[i-2][j-1]='*';
                    if (j+1<9 && L[i-2][j+1]=='0')
                        L[i-2][j+1]='*';
                    if (j-2>0 && L[i-1][j-2]=='0')
                        L[i-1][j-2]='*';
                    if (j+2<9 && L[i-1][j+2]=='0')
                        L[i-1][j+2]='*';
                }
                else if (i-1>0)
                {
                    if (j-2>0 && L[i-1][j-2]=='0')
                        L[i-1][j-2]='*';
                    if (j+2<9 && L[i-1][j+2]=='0')
                        L[i-1][j+2]='*';
                }
                if (i+2<9)
                {
                    if (j-1>0 && L[i+2][j-1]=='0')
                        L[i+2][j-1]='*';
                    if (j+1<9 && L[i+2][j+1]=='0')
                        L[i+2][j+1]='*';
                    if (j-2>0 && L[i+1][j-2]=='0')
                        L[i+1][j-2]='*';
                    if (j+2<9 && L[i+1][j+2]=='0')
                        L[i+1][j+2]='*';
                }
                else if (i+1<9)
                {
                    if (j-2>0 && L[i+1][j-2]=='0')
                        L[i+1][j-2]='*';
                    if (j+2<9 && L[i+1][j+2]=='0')
                        L[i+1][j+2]='*';
                }
            }
    return true;
    for( i=1 ; i<=9; i++)
        for (j=1 ; j<=9; j++)
        {
            if (L[i][j]=='0')
                return false;
        }
}
//(*******************************************************************************)
void printBoard(char L[][9])
{
    int i,j;

    for (i=1 ; i<9 ; i++)
    {
        for (j=1 ; j<9 ; j++)
        {
            printf("%2c|",L[i][j]);
        }
        printf("\n");
        j=1;
    } ...

Here is what i have so far:

    #include <stdio.h>
    #include <stdlib.h>
    #include <stdbool.h>

    //(*******************************************************************************)
    void addNulls(char L[][9], int N[], int M[])
    {
        int i,j,g;

        for (i=1 ; i<9 ; i++)
            for (j=1 ; j<9 ; j++)
                if (L[i][j]!='K')
                    L[i][j]='0';
        for (i=1 ; i <9 ; i++)
            for (j=1 ; j <9; j++)
                if (L[i][j]=='K')
                    for (g=1 ; g <9; g++)
                        if (i+N[g]>0&&i+N[g]<9 && j+M[g]>0 && j+M[g]<9 && L[i+N[g]][ j+M[g]] == '0')
                            L[i+N[g]][ j+M[g]] = '*';
    }
    //(*******************************************************************************)
    bool checkIf(char L[][9], int N[], int M[])
    {
        int i, j;

        for ( i=1 ; i<9; i++)
            for (j=1 ; j <9; j++)
                if (L[i][j]=='K')
                {
                    if (i-2>0)
                    {
                        if (j-1>0 && L[i-2][j-1]=='0')
                            L[i-2][j-1]='*';
                        if (j+1<9 && L[i-2][j+1]=='0')
                            L[i-2][j+1]='*';
                        if (j-2>0 && L[i-1][j-2]=='0')
                            L[i-1][j-2]='*';
                        if (j+2<9 && L[i-1][j+2]=='0')
                            L[i-1][j+2]='*';
                    }
                    else if (i-1>0)
                    {
                        if (j-2>0 && L[i-1][j-2]=='0')
                            L[i-1][j-2]='*';
                        if (j+2<9 && L[i-1][j+2]=='0')
                            L[i-1][j+2]='*';
                    }
                    if (i+2<9)
                    {
                        if (j-1>0 && L[i+2][j-1]=='0')
                            L[i+2][j-1]='*';
                        if (j+1<9 && L[i+2][j+1]=='0')
                            L[i+2][j+1]='*';
                        if (j-2>0 && L[i+1][j-2]=='0')
                            L[i+1][j-2]='*';
                        if (j+2<9 && L[i+1][j+2]=='0')
                            L[i+1][j+2]='*';
                    }
                    else if (i+1<9)
                    {
                        if (j-2>0 && L[i+1][j-2]=='0')
                            L[i+1][j-2]='*';
                        if (j+2<9 && L[i+1][j+2]=='0')
                            L[i+1][j+2]='*';
                    }
                }
        return true;
        for( i=1 ; i<=9; i++)
            for (j=1 ; j<=9; j++)
            {
                if (L[i][j]=='0')
                    return false;
            }
    }
    //(*******************************************************************************)
    void printBoard(char L[][9])
    {
        int i,j;

        for (i=1 ; i<9 ; i++)
        {
            for (j=1 ; j<9 ; j++)
            {
                printf("%2c|",L[i][j]);
            }
            printf("\n");
            j=1;
        }
    }
    //(*******************************************************************************)
    void modeling(char L[][9], int N[], int M[], int z)
    {
        int i,j,o;

        i=1;
        j=1;
        if (z<12)
        {
            while (L[i][j]!='0' && i<9) ...

Hi I have to write program that finds a solution how to put 12 knights to a 8x8 chess board that every square would be dominated by one of the 12 knights. Do you have any suggestions from where I can start?

Thanks for your post, I know that it's hard to read code without all program. I found the mistake:
It should be

while(tempas->fr!=NULL && tempas->fr->priority<=prrt)
                 tempas=tempas->fr;

And not:

while(tempas->fr**->prv**!=NULL && tempas->fr->priority<=prrt)
                 tempas=tempas->fr;

I am implementing Priority QUE as a doubly linked list. My structs:

typedef int kintyr;

typedef struct qElem {
    struct qElem *prv;          
    kintyr *dat;                    
    int *priority;
}qElem;

typedef struct que {
    qElem *fr,*bk;              
    int cnt;                    
}que;

And this is my functions to create empty PQ, and to insert elements:

que *qNew()
{
    que *q = malloc(sizeof(*q));

if (q==NULL)
    return NULL;

q->fr = NULL;
q->bk = NULL;
q->cnt = 0;

qFault = 0;
return q;
}

que *qEnq(que *q, kintyr *x, int *prrt)
{
    que *zn=q;
    qFault = 0;
    if (q == NULL)
    {
        qFault = 1;
        return q;
    }
    if (qCHKf(q) == 1)
    {
        qFault = 3;
        return q;
    }
    qElem *new = malloc(sizeof(*new));
    new->prv = NULL;
    new->dat = x;
    new->priority=prrt;

    if (q->fr == NULL || q->fr->priority>prrt  ) 
    {
        new->prv=q->fr;
        q->fr = new;

    }
    else
    {
        que *tempas=q;
        while(tempas->fr->prv!=NULL && tempas->fr->priority<=prrt)
            tempas=tempas->fr;

        new->prv=tempas->fr;
        tempas->fr=new;
    } 
        q->cnt++;
        return q;

}

It works good if I add for example elements with priority 7, then 4, then 5.

4->5->7
But if I add element with priority 7, then 6, then 8. It appears:

6->**8**->7
Do you have any ideas how can I fix that?