Q:

How can index a group of elements and return back an array of index in C programming

In my program, I want to find the index of elements in the array suit which is equal to 1. The IndexSuit function is going to do this and I expect to return an array from it which are the index of elements 1, say { 2, 3, 4 ,5 ,6 }. 
#include <stdio.h>

int * IndexSuit(int suitofdeck[], int suittype);

int main(int argc, char *argv[]) 
{
    int suit[13] = { 0,0,1,1,1,1,1,2,2,3,3,3,3 };
    int i;

    for (i = 0; i < 13; i++) {
        printf("%d", IndexSuit(suit, 1)[i]);
    }
}

int * IndexSuit(int suitofdeck[], int suittype) {
    int count = 0;
    int * index = calloc(13 ,13 * sizeof(int));
    int i;

    for (i = 0; i <= 13; i++) {
        if (suitofdeck[i] == suittype) {
            index[count] = i;
            count++;
        }

        return index;
    }
}

A:

The problem here seems to be where you have the return. It returns after one iteration of the loop. Looks like it should be on the line below. 
There are a couple of other improvements though I'd like to suggest. 
1) You are calling this function each time in your loop in main which is allocating memory and then you are picking one value out of it. I would suggest you call it once and then iterate through the array.
2) With your current code there is no way to distinguish between the index value of 0 and just not assigned ones (as there will be less than 13 index values and they are all initialised as zero). I would suggest that you return the number of indices actually set.
I've made a slightly modified version here:
#include <stdio.h>
#include <stdlib.h>

int * IndexSuit(int suitofdeck[], int suittype, int* numIndicies);

int main(int argc, char *argv[])
{
    int suit[13] = { 0,0,1,1,1,1,1,2,2,3,3,3,3 };
    int i;
    int* indicies;
    int numIndicies;

    indicies = IndexSuit(suit, 1, &numIndicies);
    for (i = 0; i < numIndicies; i++)
    {
        printf("%d ", indicies[i]);
    }
    printf("\n");

    free(indicies);
}

int * IndexSuit(int suitofdeck[], int suittype, int* numIndicies)
{
    int count = 0;
    int * index = calloc(13 ,13 * sizeof(int));
    int i;
    for (i = 0; i <= 13; i++)
    {
        if(suitofdeck[i] == suittype)
        {
            index[count] = i;
            count++;
        }
    }

    *numIndicies = count;

    return index;
}

This produces the result:
2 3 4 5 6 

