|
개별적으로 하면 함수는 다컴파일되더라구요,, 근데 이렇게 합쳐서 하면.. 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
|