Reading a binary data file and printing it out output file input file struct description This is
Question:
Reading a binary data file and printing it out
output file
input file
struct description
This is my code so far:
#include
#include
#include
#include
struct record{ // declare the variables // do nottouch float aunt; short mist; bool drop; short women; char chess; double language; bool cover; bool circle; unsigned char clam; unsigned int current; long int elbow; float zephyr; short int reason; unsigned char bridge; char minute[7]; long int twist;};
int main(int argc, char **argv){
FILE *f;
struct record rec1;
fopen(argv[1], "rb");
fread(&rec1, sizeof(argv[1]), sizeof(argv[1]), f);
if (f == NULL){
fprintf(stderr, "%s doesn't exist!", argv[1]);
exit(1);}
if (!f){
printf( "Usage: %s inputfile", argv[1]);
exit(1);}
fclose(f);
printf("aunt, mist, drop, women, chess, language, cover, circle,clam, current, elbow, zephyr, reason, bridge, minute,twist");
printf("%f,%hi,%d,%hi,%c,%f,%d,%d,%u,%u,%ld,%f,%u,%u,%s,%ld",rec1.aunt,rec1.mist, rec1.drop, rec1.women, rec1.chess, rec1.language,rec1.cover, rec1.circle, rec1.clam, rec1.current,rec1.elbow,rec1.zephyr, rec1.reason, rec1.bridge, rec1.minute,rec1.twist);
return 0;
}
--Please assist in code if any mistakes
--Please explain how to execute in command propt.
please help in completing code
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill