My Code is HERE
int main(){
FILE *fp;
fp = fopen("dic.txt", "r");
while(getc(fp) != EOF){
if(getc(fp) == ' '){
printf("up ");
}
}
}
My dic.txt is HERE
my predict is that "up up up up "
because, there are four space " "
but it printed "up " only one
what is problem?
You want this:
getc
once only in the loop, otherwise you skip one out of two characters.fopen
fails.