I am trying to take a string as input and if it's equal to X++ or ++X, I would like to count it. for this purpose, I have written value code. Though it's working correctly for X++, for X-- it's not working. How can I solve the problem?
#include<stdio.h>
#include<string.h>
int main() {
int n,count=0;
char c[5];
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%s",c);
if(strcmp(c,"X++")==1 || strcmp(c,"++X")==1) count++;
else count--;
}
printf("%d",count);
return 0;
}