i have problem that the the loop to check if a digit is correct but not at the right place.
then print.

void feedback( char random[4], char guess[5])
{
    int i;

    for(i=0; i<4; i++)
    {
        if(guess[i]==random[i])
        {
            printf("#");
        }
    }


        if((guess[0]==random[1]||guess[0]==random[2]||guess[0]==random[3])&&guess[0]!=random[0])
        {
            printf("*");
        }
        if((guess[1]==random[0]||guess[1]==random[2]||guess[1]==random[3])&&guess[1]!=random[1])
        {
            printf("*");
        }
        if((guess[2]==random[0]||guess[2]==random[1]||guess[2]==random[3])&&guess[2]!=random[2])
        {
            printf("*");
        }
        if((guess[3]==random[0]||guess[3]==random[1]||guess[3]==random[2])&&guess[3]!=random[3])
        {
            printf("*");
        }
        printf("\n");

}

how to make sure the same digit is not used twice?

Do a for loop checking each number of guess with numbers after it and give error or do not accept guess, if you find same ones.

how to make sure the same digit is not used twice?

If you use it once, remove it from the list.

For example:

for(i=0; i<4; i++)
{
    if(guess[i]==random[i])
    {
        printf("#");
        guess[i] = -1;  // remove the guess since it's been used
    }
}