全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:845
推到 Plurk!
推到 Facebook!

code test

 
williamfox
一般會員


發表:14
回覆:15
積分:5
註冊:2002-08-05

發送簡訊給我
#1 引用回覆 回覆 發表時間:2007-09-26 12:48:13 IP:61.230.xxx.xxx 未訂閱

[code cpp]
#include
#define LEN 16348//filepath & filename
#define EXIT_SUCCESS 0
//************** Mail body ****************** //

int vector_count(char *str);
int line_count(char *str,int P_LEN);

int main(int argc, char *argv[])
{
char vector_bit[LEN]="TestList_fortest.do";
FILE *srcfptr,*targetfptr; // FILE pointer
char fin[LEN],fout[LEN];

if(argc < 3){
printf("Input Parameter Error. \n");
system("\n PAUSE");
system("cmd");
return EXIT_SUCCESS;
}
else{
strcpy(fin,argv[1]);
strcpy(fout,argv[2]);

srcfptr=fopen(fin,"r");
targetfptr=fopen(fout,"w ");

if (srcfptr==NULL||targetfptr==NULL){
printf("Open File is Fail , Please check again. \n");
system("\n\n PAUSE");
return EXIT_SUCCESS;
}
}


int lines=0;
char temp_ch_01[(vector_count(vector_bit) 1)];
while(fgets(temp_ch_01,(vector_count(vector_bit) 1),srcfptr)!=NULL){
lines ;
printf("%s",temp_ch_01);
break;
}



printf("%d\n",lines);
//printf("%s\n",temp_ch_01[vector_count(vector_bit)]);
//printf("%s\n",temp_ch_01[vector_count(vector_bit)-2]);
//printf("%s\n",temp_ch_01[vector_count(vector_bit)-1]);
//printf("%s\n",temp_ch_01[vector_count(vector_bit)]);



// printf("%d\n\n",line_count(fin,vector_count(vector_bit)) );
// printf("%d\n\n",vector_count(vector_bit));
fclose(srcfptr);
fclose(targetfptr);
system("PAUSE");
return EXIT_SUCCESS;
}















































































int vector_count(char *str)
{
int row_count=0;
char temp_ch;
FILE *fptr=fopen(str,"r");// FILE pointer
while((temp_ch=fgetc(fptr))!=EOF){if (temp_ch==('\n')){row_count ;}}
fclose(fptr);
return row_count;
}


int line_count(char *str,int P_LEN){
int lines;
char temp_ch_01[P_LEN];
FILE *fptr=fopen(str,"r");

while(fgets(temp_ch_01,P_LEN,fptr)!=NULL){
//printf("%s , %d ",temp_ch_01,lines);
lines ;
}
return lines;
}

[/code]
系統時間:2024-04-24 4:25:46
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!