用C语言编写复制MP3文件的程序
本人刚学c,想写一个复制MP3文件的程序,不知道怎么写,求源码!
[解决办法]
#include <stdio.h>int mp3cpy(const char* sname, const char* dname){#define BUF_SIZE 2048 FILE* sfile; FILE* dfile; unsigned char buffer[BUF_SIZE]; size_t size; sfile = fopen(sname, "r"); dfile = fopen(dname, "w"); if(sfile == NULL || dfile == NULL) { return -1; } do{ size = fread(buffer, 1, BUF_SIZE, sfile); fwrite(buffer, 1, size, dfile); }while(size == BUF_SIZE); fclose(dfile); fclose(sfile); return 0;}int main(int argc, char* argv[]){ return mp3cpy("29a.mp3", "29b.mp3");}
[解决办法]
"rb"
"wb"
不要把
fopen("...","...");fscanf,fprintf,fclose //读时把\r\n替换成\n,写时把\n替换成\r\n;读到\x1a就设置EOF;读写的内容当字符看待
和
fopen("...","...b");fread,fwrite,fclose //不作以上替换,遇到\x1a仍继续读;读写的内容当字节看待
弄混了
system("copy /y 29a.mp3 29b.mp3");//这样似乎更简单
计算机组成原理→DOS命令→汇编语言→C语言(不包括C++)、代码书写规范→数据结构、编译原理、操作系统→计算机网络、数据库原理、正则表达式→其它语言(包括C++)、架构……
[解决办法]
复制MP3文件,不就复制文件嘛。。
system("copy /b pathA pathB");
[解决办法]
BOOL WINAPI CopyFile( __in LPCTSTR lpExistingFileName, __in LPCTSTR lpNewFileName, __in BOOL bFailIfExists);
[解决办法]