Q:

long integer as array index in C gives segmentation fault

The following C Code gives a segmentation fault:
#include <stdio.h>
#include <stdint.h>

int main(){
        uint32_t *a;
        uint32_t idx=1233245613;
        a[idx]=1233;
        return 0;
}

How can I use uint32_t as index of an array in C? Or how can I use array like structure which can get uint32_t and 12 digit numbers as an index?
I'd appreciate any kind of help.

A:

The variable "a" is just a pointer varaible.  
A pointer variable holds the address of a memory location.
You need to point a to a memory location that has the space you need already allocated.

Also you are trying to index pretty far in the array.  You may not have enough memory available for this so be sure to check for NULL.
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>

int main(void){

        uint32_t *a;
        uint32_t idx=1233245613;

        //This allows you to index from 0 to 1233245613
        // don't try to index past that number
        a = malloc((idx+1) * sizeof *a);
        if(a == NULL)
        {
           printf("not enough memory");
           return 1;
        }

        a[idx]=1233;
        free(a);
        return 0;
}

A:

If you want to use a "12-digit number" as the index, that implies that you want need more than 1 billion items. With each item being an uint32_t, that implies that each takes four bytes of memory. Therefore, you're looking at around 4 GB in memory total for this array. Arrays are not usually made that big, for performance and other reasons.
If you really need each of those billion items, look into disk-backed algorithms, perhaps Red-Black Trees, that are suitable for implementing this kind of giant array.

