我只需要知道我该做什么,3Q
会有附加分的
1
Write a file copy program that copies an existing file into another file. The program should ask the user to enter the source file name and destination file name. The file copy should be performed in binary mode. Use fseek() to move within the source file and ftell() to determine the size of the file (if needed). Read the data from the source file and write the values read in the destination file in a loop. Read and write data in blocks of 1024 bytes.
2The following program reads from a text file containing numeric data stored in columns separated by one blank space. Write the code and compile it on your computer. Create a text file called myfile.txt containing a few columns (35 for example) of numeric data (real numbers) and test the program.
Analyse the code and include comment lines explaining how the program achieves its task. Modify the code so that the program additionally creates a new text file where it stores only the integer part (discard the factionary part) of the real numbers stored in myfile.txt. The new file should write data in the same format (35 with columns separated by space) as the original file. Include statements to check if the file was opened and closed successfully. Submit only the final, commented code.
3
Create a text file containing 20 rows of 20 integers separated by spaces. The integers should be in the range 0-9 and separated by spaces. Write a program that reads the contents into a 2020 (two dimensional) array of int. The program then should use this array to initialize a 20x21 array of char by associating each integer from 0 to 9, with a character from ‘A’ to ‘J’. For example, 0 could be associated with ‘A’, while 9 with ‘J’. The 21st character on each line in the array of char should be the null character ‘\0’, making the array an array of 20 strings. Have the program display the resulting (picture) array of char (printing row-by-row the strings) on screen, and also write it in into a text file.