英语翻译我只需要知道我该做什么,3Q会有附加分的1Write 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 b
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/15 20:55:10
英语翻译我只需要知道我该做什么,3Q会有附加分的1Write 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 b
英语翻译
我只需要知道我该做什么,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.
英语翻译我只需要知道我该做什么,3Q会有附加分的1Write 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 b
翻译这么多文字真是一件不简单的事情,但是我敢保证,遇到我是你的幸运!
以下是我翻译的:
1
写一个文件拷贝的程序,拷贝一个已经存在的文件到另外一个文件.程序必须告诉用户输入源文件名和目标文件名.文件拷贝必须以二进制的方式执行.使用fseek()在源文件里移动,和ftell()确定文件的大小(如果需要的话).在一个 循环里面,读取源文件的数据然后将读到的数据写进目标文件.一次读写一块数据,每块数据的大小为1024字节.
2
以下程序(原题是不是给出程序?)读取一个保存着数字资料的文本文件,这些数字按列存储,并以一个空格分开.在你的电脑里编写代码并编译.创建一个文本文件,名叫myfile.txt,包含几列数字(实数),然后测试这个程序.
(注:题目只说按列存储,并没有说是几行,可能只要一行,也可能有多行,你没有给出原题的程序,我也不好下结论;题目要求实数,那么可以用浮点型,
如 2.1 5.4 6 9 4.5,每个数字用空格分开)
分析程序代码,然后添加一些注释以说明程序是如何完成它的任务的.修改代码以让程序另外产生一个新的文件存储myfile.txt文件里的实数的整数部分(忽略小数部分,那么2.1就变成2,5.4变成5).新的文件必须按照源文件的格式写进数据.程序还包含检查语句,以确认文件被成功的打开和关闭.
3
创建一个文本文件,包含有20行,每行是以空格分开的20个整数(即20行20列).这些整数必须是0-9的范围内并以空格分开.写一个程序,读取文件的内容到一个20*20(二维)的int型数组.然后用这个数组去初始化一个20*21的char型数组,数字0到9,分别对应字符A到J.例如,0和A对应,9和J对应.char数组的每一行的第21个字符必须是空字符'\0',将数组制作成一个包含20个字符串的数组.让这个程序在屏幕显示最终的char数组(打印一行接一行的字符串),同时也把它写进一个文本文件里.
(注:简单的说,就是要把二维的char数组的每一行当成字符串输出,C语言的字符串是以空字符'\0'结尾的,所以这样做很容易理解)