Write code to open a file called adata.out, and write the contents of the follow
ID: 3621376 • Letter: W
Question
Write code to open a file called adata.out, and write the contents of the following array out to it in binary form (with no data conversion).int a[5];
What would be the best file mode for each of the following cases?
a. reading binary data in an existing file
b. adding new text data to the end of an existing file
c. replacing the current contents of an existing file with new text data, then modifying the new data
You are writing a function that has to keep track of the number of times it is called. What storage classes could be used for a variable that could retain this information? Which one would you recommend?
Describe how the const qualifier was used to "improve," that is, make more readable and reliable, the program in Listing 14.8, pages 545-46.
Define a structure template that will contain the following data:
a. Account number
b. Account owner street address (string)
c. Account owner city/state (string)
d. Account owner zip code
e. Account balance
f. Account credit limit
g. A pointer to another instance of this structure type
Define a structure variable using this template, and initialize it. The pointer should be initialized so that it does not point to any valid address. Use printf to print the contents of all of the structure variable's members, including the pointer.
Explanation / Answer
Dear, 1. #include int main() { int a[5] = {1,2,3,4,5}; FILE *pfile; /* File pointer to desired file */ int i = 0; pfile = fopen("adata.out", "ab"); /* opens file append-binary */ /* checks for file empty*/ if(pfile==NULL) { printf("Error: can't open file. "); return 1; } else for(i =0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.