I am new here so sorry for any misunderstanding. I am learning Random Access File on C Language. And I am confused about the variable blankClient. It is not an array, but how could Deitel (the author) initialize 100 blanks record using blank Client. I though it should be like: struct clientdata blankClient[100];
/*Creating a random-access file sequentially */
#include <stdio.h>
struct clientdata {
int acctNum; /*account number*/
char lastname[15]; /*account last name*/
char firstname[10]; /*account first name */
double balance; /*account balance*/
};
int main (void){
int i; /*counter used to count from 1-100 */
/*create clientData with default info */
struct clientdata blankClient = {0, "","", 0.0};
FILE *cfPtr; /*credit.dat file pointer */
if ((cfPtr =fopen("credit.dat", "wb")) == NULL) {
printf("File could not be opened. \n");
}
/*output 100 blank records to file */
else {
for (i=1; i<=100; i++) {
fwrite(&blankClient, sizeof( struct clientdata), 1, cfPtr);
}
fclose (cfPtr);
}
return 0;
}