当前位置: 代码迷 >> C语言 >> 循环嵌套问题
  详细解决方案

循环嵌套问题

热度:213   发布时间:2007-11-22 19:57:35.0
循环嵌套问题
#include <stdio.h>
#include <stdlib.h>
#define FILEREAD "E:\lanhu.zip"
#define FILEWRITE "E:\lanhu.lhr"
struct lhrBody{
long int n;
char body;
}*lhr; //存储信息结构
char getFilesize(char *filePath);//得到文件长度
int fileSize=0;
int main(){
char c,s,tc;
int i=0,n;
FILE *fpr,*fpw;
getFilesize(&FILEREAD);
printf("The file size :%ld\n",fileSize);
if((fpr=fopen(FILEREAD,"rb"))==NULL){
  printf("The File:%s Open Failed",FILEREAD);
  exit(0);}
if((fpw=fopen(FILEWRITE,"wb"))==NULL){
  printf("The File:%s Open Failed",FILEWRITE);
  exit(0);
}
s=fgetc(fpr);
c=s;
while(n!=fileSize){//循环开始
tc=fgetc(fpr);
n++;
printf("%ld ",n);
if(s!=tc){(*lhr).n=i;(*lhr).body=c;fwrite(lhr,sizeof(lhr),sizeof(lhr),fpw);s=tc;break;}
else{i+=i;c=s;s=fgetc(fpr);break;}
}
return 0;
}
char getFilesize(char *filePath){
FILE *fp;
if((fp=fopen(filePath,"r"))!=NULL){
  fseek(fp,0L,SEEK_END);
  fileSize=ftell(fp);
  return fileSize;
  //printf("The file size :%ld",fileSize);
}
exit(0);
}
我这个代码那里出错了?初学者,找了半天找不到那里的问题拜托了!
搜索更多相关的解决方案: 嵌套  int  FILEREAD  char  

----------------解决方案--------------------------------------------------------
#define FILEREAD "E:\\lanhu.zip"
#define FILEWRITE "E:\\lanhu.lhr"
----------------解决方案--------------------------------------------------------
  相关解决方案