c++实现文件的下载更新

2024-05-11 02:21

1. c++实现文件的下载更新

1. 服务器如果提供 IIS WEB SERVICE, 那可以用 C++写个 HTTP GET的程序下载文件,下载失败从头再下载。
2. 用 IIS作为 WEB SERVICE,可以用 HTTP协议上传,下载文件

c++实现文件的下载更新

2. c++文件下载函数代码?

错误

3. C++mfc编程中,点击一个按钮,实现从网上下载东西的功能。求代码和注释。

#include #include #include #pragma comment(lib,"urlmon.lib")using namespace std;int main(){	//第一个参数为接口控件,不是控件则为0	//第二个参数为要下载的URL地址,不能为空	//第三个参数是下载后保存的文件名	//第四个参数是保留字段,必须为0	//第五个参数是下载进度状态回调    HRESULT hr = URLDownloadToFile(0,_T("http://w.x.baidu.com/alading/anquan_soft_down_b/11880"),_T ("D:\\PPTV.exe"), 0,NULL);      if (hr== S_OK)    {        cout<< "ok"<< endl;  //下载成功则输出OK    }    return 0;}这是我根据surmount_yu的回答写的控制台下载代码,经测试可以正确下载。你把URLDownloadToFile这个函数写到你的按钮响应里即可。

C++mfc编程中,点击一个按钮,实现从网上下载东西的功能。求代码和注释。

4. 用C++编写程序 实现将文件1 拷到文件2中

#include
#include

void main(int argc,LPTSTR argv[])
{
 if(argc!=3)
 {
  printf("Usage: CopyFile filel file2\n");
 }
 if(!CopyFile(argv[1],argv[2],FALSE))
 {
  printf(" CopyFile Error: %x\n",GetLastError());
 }
}
编译完成后,生成一个CopyFile.exe文件,将之拷贝到系统默认的文件夹内(比如:C:\windows\system32\;如果没有拷贝到系统默认可执行文件夹内,在CMD窗口内转到该文件所在的文件夹上),在CMD命令窗口执行该可执行程序(键入:CopyFile filename1 filename2),两个filename必须是全名才行。

5. C++编程实例如何下载

收不到么?、、

1.快速入门 
〈Accelerated.C++〉2000 
〈Essential C++〉2002 Lipman 
两本都是开篇就讲C++/STL,绝口不提C,而且都有中文版。 

2.枕头参考 
〈C++.Primer.4th〉2005 Lippman,第3版有中文版,当入门书看也无不可。 
〈The.C++.Programming.Language.3rd〉Bjarne Stroustrup ,简称TCPL。 

3.专门书籍 
STL参考:〈The.C++.Standard.Library-A.Tutorial.And.Reference〉1999 
号称最好的STL参考,但我觉得很像JDK文档。 

Boost 参考:〈Beyond the C++ Standard Library - An Introduction to Boost〉2005 
介绍了Boost的一些重要类库,但其余的还是要看Boost自带文档。 

C++ Template参考:〈C++ Templates - The Complete Guide〉2002 
对template讲得相当深,无愧于The Complete Guide的书名,ytam说可以作为MCD的前传和续集。 

〈C++ Common Knowledge〉 中文版, Stephen C. Dewhurst 
跑杯茶怡然的看看C++里面那些值得吹嘘的知识点是个不错的场景。 

4.Effective 类 
Herb Sutter, Andrei Alexandrescu合著一本: 
〈C++.Coding.Standards - 101.Rules.Guidelines〉2004 

Meyers的三本Effecive: 
〈Effective C++ 3rd〉 2005 
〈More Effective C++〉 
〈Effective.STL.50.Specific.Ways.to.Improve.Your.Use.of.STL〉 

〈C++ Gotchas〉2002,Stephen C. Dewhurst 

对于后四本,我老觉得是在语言规范下绕来绕去,从工作角度来看是实用,从个人角度看来是无聊。 

5.精力过剩类 
〈Modern C++ Design - Generic Programming and Design Patterns 〉2001 Andrei Alexandrescu ,推荐,C++里最值得一读的书。 

〈C++ Template Metaprogramming Concepts,Tools and Techniques from Boost and Beyond 〉 

Herb Sutter的三本Exceptional,rayman说是打击信心用的: 
〈Exceptional C++ - 47 Engineering Puzzles, Programming Problems, and Solutions 〉1999 
〈More Exceptional C++〉2001 
〈Exceptional C++ Style - 40.New.Engineering.Puzzles.Programming.Problems.and.Solutions〉2004

C++编程实例如何下载

6. C++实现:8.编程实现:将一个文本文件的内容拷贝到另一个文本文件中。

程序代码:
#include 
#include 
using namespace std;
void main()
{
	char ch;
	ifstream file("C:/test.txt");//读取c盘的文本文件
	ofstream file1("C:/test1.txt");//创建文本文件
	while(file.get(ch))//读取文本中的内容
	{
		cout << ch;//输出文本内容到控制台
		file1<<ch;//写入内容到文件
	}
	file.close();   //关闭文件流
	file1.close();
	cout<<endl;
} 
注意这个程序会清空text1.txt中的内容然后在写入
以下的程序代码不会
程序代码:
#include 
#include 
using namespace std;
void main()
{
	char ch;
	ifstream file("C:/test.txt");//读取c盘的文本文件
	ofstream file1("C:/test1.txt",ios::app);//创建文本文件
	while(file.get(ch))//读取文本中的内容
	{
		cout << ch;
		file1<<ch;//写入内容到文件
	}
	file.close();   //关闭文件流
	file1.close();
	cout<<endl;
}

7. C++编写程序,实现把file1.txt的内容拷贝到文件file2.txt。

#include"stdio.h"
void main()
{
    FILE *fp_in,*fp_out;
    charinfile[20],outfile[20];
    printf("Entertheinfilename:\n");
    scanf("%s",infile);
    printf("Entertheoutfilename:\n");
    scanf("%s",outfile);
    if((fp_in=fopen(infile,"r"))==NULL)
    { 
         printf("Can't openfile%s\n",infile);
         getchar();
         exit(0);
     }
     if((fp_out=fopen(outfile,"w"))==NULL)
    { 
         p rintf("can't openfile%s\n",outfile);
         getchar();
         exit(0);
    }
   while(!feof(fp_in))
       fputc(fgetc(fp_in),fp_out);
       fclose(fp_in);
       fclose(fp_out);
}

PS:这个是在网上找到的,你看看能不能用吧, C++是兼容C的

C++编写程序,实现把file1.txt的内容拷贝到文件file2.txt。

8. 利用C++的流类库,编程实现任意磁盘文件的拷贝。

//---------------------------------------------------------------------------
#include 
#include 
#include 

using namespace std ;

int main(void)
{
 ifstream inf;
 ofstream ouf;
 string fsname,ftname;
 char buf[1024];
 cout<<"FROM:";
 cin>>fsname;
 cout<<"TO:";
 cin>>ftname;
 inf.open(fsname.c_str(),ifstream::binary);
 ouf.open(ftname.c_str(),ofstream::binary);
 if (!inf||!ouf) {
  cerr<<"FILE ERROR"<<endl;
  return -1;
 }

 while (!inf.eof())
  {
     inf.read(buf,1024);
     ouf.write(buf,inf.gcount());
  }
 inf.close();
 ouf.close();

 return 0;
}
//---------------------------------------------------------------------------
最新文章
热门文章
推荐阅读