当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

 ·ftp的源程序,欢迎指教    »显示摘要«
    摘要: 以下是我的部分ftp源程序,可以实现客户端到服务器的上传,可是只能实现某个目录下的一个文件的上传,有谁能实现将客户端整个目录下的所有文件上传到服务器的? private void button1_click(object sender, system.eventargs e) { ftpfactory ff = new ftpfactory(); ff.setdeb......
    摘要: 怎么该登陆密码啊,原来的那个忒难记了 ......


分割文件的问题

各位高手:我写了一个将一个上万行的文本文件,分割成四百行的小文件。程序应该简单,只是需要建立若干个文件,然后将内容写进去。但是在执行时,报"open   cut   file     fail!"错,请各位高手指点错在哪里。非常感谢!  
  #include   <stdio.h>  
  #include   <string.h>  
  #include   <process.h>  
   
  void   main()  
  {  
  FILE   *outfp;  
  FILE   *cutfp;  
   
   
   
  int   i;  
   
  char   postfix   =   a;  
  char   filename[20]   =   "gzdest_";  
  char   buf[512]="0";  
   
   
  outfp   =   fopen("gzdest.txt",   "r");  
  if   (outfp   ==   NULL)  
  {  
  printf("open   gzdest.txt   file     fail!");  
  exit(0);  
  }  
   
   
  //将文件分成小块  
  while   (!feof(outfp))  
  {  
   
  strcat(filename,&postfix);  
  strcat(filename,".txt");  
   
  cutfp   =   fopen(filename,   "w");  
  if   (cutfp   ==   NULL)  
  {  
  printf("open       cut   file     fail!");  
  exit(0);  
  }  
   
  for   (i   =0;   i   <   400;   i++)  
  {  
  fgets(buf,sizeof(buf),outfp);  
  fputs(buf,cutfp);  
  }  
  if   (i   ==   400)  
  {  
  i=   0;  
  postfix++;  
  fclose(cutfp);  
  }  
  }  
   
   
  fclose(outfp);  
  fclose(cutfp);  
   
   
  }  
 

NO.1   作者: zhang1000

呵呵  
  strcat(filename,&postfix);  
  strcat(filename,".txt");  
  好象有好多问题....  
  postfix是char,   &postfix是地址,可能产生不存在的文件名....  
   
  按你的意思,   第一次应该产生gzdest_a.txt,可是第二次就会是gzdest_a.txtb.txt;....  
  另外a,b,c....很容易就到达不可打印字符.  
  可以定文件名为:  
  int   fileno=0;  
  while   (!feof(outfp))  
  {  
  sprintf(filename,   "gzdest_%d.txt",   fileno);  
  ...  
  }  
   
  另外重新开始读文件的时候不设置偏移量,会每个文件的内容都一样...  
  如果这种方式的话,可能要读去N个字节,这样好计算偏移量...  
   
 


    摘要: 我用的是 windows2000 professional 的操作系统.装sql server 时候提示我,只能安装它的客户端程序. 是否在不换操作系统的情况下,安装sql server 服务器程序. 谢谢! ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE