/*
I'd like to read some data from hard disk & then manipulate them as const variables. Here a simple version is attached. I do not know how to Initialize a const array by FUNCTION */

#include <stdlib.h>
#include <stdio.h>
int *MAKE(const int n,int i)
{
    int V[n];
    V[0]=10*i;
    V[n-1]=2;
    printf("%d",V[0],V[n-1]);
    return V;
}

int main()
{
    const int n=5;
    int i=2;
    int *A_Load=MAKE(n,i);
    printf("%d",A_Load[0],A_Load[n-1]);
    return 1;
}

<< moderator edit: added code tags: [code][/code] >>

Consider malloc/free to create the array. Functions that use the array should take a pointer to const.

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.