C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[24830] 제가작성한 간단한 프로그램 자꾸 오류가 나서요, 확인점 해주세요...
c언어초보자 [] 822 읽음    2003-03-21 06:45
개별적으로 하면 함수는 다컴파일되더라구요,, 근데 이렇게 합쳐서 하면.. file open error이나와
요, 왜그런건지.알려주세요


#include <stdio.h>
#include <stdlib.h>

/*알파벳 확인 함수*/

int alp(char c)
{
  if ((c>='a' && c<='z') || (c>='A' && c <= 'z'))
      return(1);
  else
      return(0);
}
/*한줄읽기함수1*/

readline1(char buffer1[])
{
char ch;
int i=0;
FILE *aa;
aa = fopen("a.txt","r");
  if( aa == NULL )
  {
    printf("file open error \n");
    exit(1);
   }
 
   
do {
      ch=getc(aa);
       buffer1[i]=ch;
    ++i;
     }
while(ch != '\n');


     buffer1[i -1] = '\0';

}



/*단어의수 센다 함수*/

int count(char string[])

{
   int i,looking =1,wordc =0;

  for(i=0;string[i] !='\0'; ++i)
    if(alp(string[i])){
       if(looking){
       ++wordc;
       looking=0;
       }
    }else
       looking=1;

  return(wordc);
}
     

main()
{

    char text[81];
    int end=0, total =0;

  while ( ! end) {
    readline1(text);

    if (text[0] == '\0')
        end=1;
    else
      total+=count(text);

    }
    printf("%d",total);

  

}


a.txt: apple                              
       pineapple 
       strawberry
       tomato 
       orange 
       watermelon
       melon
       mango
       cherry
       grapes
b.txt :embryo
       plum
       banana
       lemon 
       strawberry
       orange 
       watermelon
       peach
       mango
       cherry
       grapes

+ -

관련 글 리스트
24830 제가작성한 간단한 프로그램 자꾸 오류가 나서요, 확인점 해주세요... c언어초보자 822 2003/03/21
32109     Re:제가작성한 간단한 프로그램 자꾸 오류가 나서요, 확인점 해주세요... 조성택 892 2003/03/22
32108     Re:제가작성한 간단한 프로그램 자꾸 오류가 나서요, 확인점 해주세요... 둘리 689 2003/03/21
32107     Re:제가작성한 간단한 프로그램 자꾸 오류가 나서요, 확인점 해주세요... 둘리 769 2003/03/21
32106     Re:제가작성한 간단한 프로그램 자꾸 오류가 나서요, 확인점 해주세요... 김영민 733 2003/03/21
24859     Re:제가작성한 간단한 프로그램 자꾸 오류가 나서요, 확인점 해주세요... c언어초보자 679 2003/03/22
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.