Codes:

#define MAX_BUFFER_SIZE 1000
int ch = 0, alpha [25] = {0}, buffer[MAX_BUFFER_SIZE] = {0} ,count = 0;

....

while ((ch = (fgetc(stream)))!=EOF)
    {
        buffer [count] = ch;
        count++;
    }

printf("%d", alpha [25]);

.....

The problem is: alpha [25] contains buffer [0], (alpha[25] is supposed to be 0). which suggests that the memory space allocated for alpha[25] is also the starting memory space of buffer[0]!!! How could this be? I am ultimately confused. Is there anything wrong with my computer?

Any help is deeply thanked.

alpha [25] is off the end of the array. Arrays are indexed from 0 to N-1, which means an array declared as

int alpha[25];

may be indexed from 0 to 24.

im confused with your explaination of your problem.....
maybe you mean ... the index of alpha will be the value of buffer[0]..
then use..

x=buffer[0];
printf("%d",apha[x]);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.