correct format for function prototype

Posted by yCalleecharan on Stack Overflow See other posts from Stack Overflow or by yCalleecharan
Published on 2010-04-04T17:28:17Z Indexed on 2010/04/04 17:33 UTC
Read the original article Hit count: 287

Filed under:
|
|
|

Hi, I'm writing to a text file using the following declaration:

void create_out_file(char file_name[],long double *z1){
FILE *out;
int i;

if((out = fopen(file_name, "w+")) == NULL){
    fprintf(stderr, "***> Open error on output file %s", file_name);
    exit(-1);
    }


for(i = 0; i < ARRAY_SIZE; i++)
fprintf(out, "%.16Le\n", z1[i]);
fclose(out);
}

Where z1 is an long double array of length ARRAY_SIZE. The calling function is:

create_out_file("E:/first67/jz1.txt", z1);

I defined the prototype as:

void create_out_file(char file_name[], long double z1[]);

which I'm putting before "int main" but after the preprocessor directives. My code works fine.

I was thinking of putting the prototype as

void create_out_file(char file_name[],long double *z1). 

Is this correct? *z1 will point to the first array element of z1.

Is my declaration and prototype good programming practice?

Thanks a lot...

© Stack Overflow or respective owner

Related posts about prototype

Related posts about pointers