#include int main(int argc, char** argv) { // write the file // FILE* fp = fopen(argv[1], "w"); float x = 27.0; fwrite(&x, sizeof(float), 1, fp); fwrite(&x, sizeof(float), 1, fp); unsigned char d = 27; fwrite(&d, sizeof(unsigned char), 1, fp); double y = 27.0; fwrite(&y, sizeof(double), 1, fp); short int s[] = {-27, -27, -27, -27, -27, 27, -27, 27}; fwrite(s, sizeof(short int), 8, fp); fclose(fp); // read the file // FILE* fp2 = fopen(argv[1], "r"); float x1, x2; fread(&x1, sizeof(float), 1, fp2); fread(&x2, sizeof(float), 1, fp2); fprintf(stdout, "(1) %f %f\n", x1, x2); unsigned char d1; fread(&d1, sizeof(unsigned char), 1, fp2); fprintf(stdout, "(2) %d\n", d1); double y1; fread(&y1, sizeof(double), 1, fp2); fprintf(stdout, "(3) %f\n", y1); float sum = x1 + x2 + d1 + y1; short int s1; while (fread(&s1, sizeof(short int), 1, fp2) > 0) { sum += s1; fprintf(stdout, "(4) %d\n", s1); } fclose(fp2); fprintf(stdout, "the sum of the values in %s is %f\n", argv[1], sum); // exit gracefully // return(0); }