/* * ninewrite.c - Writing to binary files */ #include #include // gives us fwrite? int main(void) { FILE * fp; float count; float num; if( (fp=fopen("numbers", "wb")) == NULL ) // open file 'numbers' for wrinting in binary mode // assign file handle address to pointer fp // if address is NULL exit { printf("Cant Open file nubmers\n" ); exit(1); } for(count=0.0; count<=9.0; count=count+1.0) { num=count/9.0; fwrite(&num, sizeof(float), 1, fp); // copy data in at address &num // with element size of a float // and 1 element to be coppied // to the file pointer fp } fclose(fp); return 0; }