I'm trying to make a code that count the inputs inputted one by one without counting blanks and . as MARK
#include "boolean.h"
#include <stdio.h>
#define MARK '.'
char currentChar;
boolean EOP;
void ADV(){
if(currentChar == MARK){
EOP = true;
} else{
scanf("%c",¤tChar);
}
}
void START(){
scanf("%c",¤tChar);
if(currentChar == MARK){
EOP = true;
}
}
char GetCC(){
return currentChar;
}
boolean IsEOP(){
return (currentChar==MARK);
}
int hitungkarakter(char karakter)
{
int i = 0;
if(karakter != " " && karakter != MARK){
i++ ;
}
return i;
}
int main(){
START();
int i = 0;
while(!IsEOP()){
i+=hitungkarakter(currentChar);
ADV();
printf("%d\n",i);
}
}
However, the algorithm i+=hitungkarakter adds twice everytime. How do I fix this?
It works fine if I add . directly but other inputs prints out twice. One such example:
f
1
m
2
3
k
4
5
.
6