무슨 문제일까요?? ㅜㅜ
#include
#include
#include
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
void main(void)
{
FILE * pFile;
char seq;
char cSeq[2]={0};
int numSeq=0;
char* compleSeq=NULL;
compleSeq = (char*)malloc(2000000000*(sizeof(char)));
printf("%p\n",compleSeq);
memset(compleSeq, 0,2000000000*(sizeof(char)));
strncpy(compleSeq,"start from here\n",18);
printf("%s",compleSeq);
pFile=fopen ("C:\\Users\\Administrator\\Documents\\data\\chrl.txt","r");
if (pFile==NULL) perror ("Error opening file");
else
{
do {
seq = fgetc (pFile);
numSeq++;
if (seq == 'A') { strncpy(cSeq ,"T",1); strncat(compleSeq,cSeq,1);}
else if(seq == 'T') { strncpy(cSeq , "A",1); strncat(compleSeq,cSeq,1);}
else if(seq == 'G') {strncpy(cSeq , "C",1); strncat(compleSeq,cSeq,1);}
else if(seq == 'C') {strncpy(cSeq , "G",1); strncat(compleSeq,cSeq,1);}
else strncat(compleSeq,"\nEnd",6);
}
while (seq != EOF);
fclose (pFile);
printf("%s \n%d",compleSeq,numSeq);
}
free(compleSeq);
}
이렇게 해봣는데 start from here 나왓다가 sequence가 나오는데 총 글자수가 230000개 정도인데(numSeq보면 연산은 되는거 같은데..) 뒷글자부터 나오다가 앞부분(start from here 포함)이 짤리고 전체 글자가 안나오네요 ㅜㅜ
https://kldp.org/node/157259
https://kldp.org/node/157259 의 답변을 읽어보세요. 이 질문의 경우에는 작은 완결된 코드가 아니라 작은 완결된 데이터가 팔요하겠지요? 설마 답변자가 직접 테스트 데이터 만들고 컴파일해서 테스트해보기를 바라시는 것은 아니겠지요? 원하는 바를 얻을 수 있게 또 상식적인 경우에 맞게 움직여야지요~~~. 그리고 code 블록으로 소스 코드를 감싸세요. 다른 글도 좀 둘러보고 사용법도 대충 살펴보고 질문을 했어야하지 않겠어요~?
댓글 달기