correct format for function prototype
- by yCalleecharan
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...