回复 28楼 玩出来的代码
你好,这是我依照您的代码,所写的程序:
程序代码:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
int main(int argc,char **argv)
{
FILE *pf=fopen(argv[1],"rb+");
fseek(pf,0,SEEK_END);
int filesize=ftell(pf);
fseek(pf,0,SEEK_SET);
int num=1024*1024;
char *pbFile=new char[num+1];
bool bFlag=false;
int target[26]={0};
if(pbFile==NULL)
{
printf("new error");
return -1;
}
while(filesize>0)
{
if(filesize<num)
num=filesize;
fread(pbFile,num,1,pf);
for(int i=0;i<num;i++)
{
while((i<num && pbFile[i]=='>') || bFlag)
{
bFlag=true;
while(i<num && pbFile[i]!='\n')i++;
if(i<num)
{
bFlag=false;
i++;
}
else if(i==num)
break;
}
while(i<num && pbFile[i]!='\r' && pbFile[i]!='\n')
target[pbFile[i++]-65]++;
}
filesize-=num;
}
delete []pbFile;
fclose(pf);
FILE *p=fopen(argv[2],"r+");
fprintf(p,"%d",target[0]+target['G'-'A']+target['C'-'A']+target['T'-'A']);
fclose(p);
cout<<target[0]+target['G'-'A']+target['C'-'A']+target['T'-'A']<<endl;
return 0;
}
不知为何,当我g++此程序时,有一下的错误信息:
程序代码:
read_count.cpp: In function `int main(int, char**)':
read_count.cpp:51: error: `cout' was not declared in this scope
read_count.cpp:51: error: `endl' was not declared in this scope
您知道,该如何解决这问题吗?
以下是我电脑的一些资料:
ia64 GNU/Linux
gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-8)
谢谢您的任何意见 :)