byu
Master
I need some help, this is example 2.1 on the ProCo 2008. I've gotten pretty far in about 5 minutes, but I'm having trouble with this one function I'm writing, and I need some help.
LANGUAGE: C
GOAL: I'm writing a function that takes in a character string and if the following two pieces of criteria are met:
1) the word is three letters
2) the second letter is A
then it returns 1. Otherwise, it returns 0. Here is what I have:
But for some reason, it always returns 0, no matter what, even when I write a word like CAR (not that the character strings will be all capital letters).
Help is appreciated, thanks.
LANGUAGE: C
GOAL: I'm writing a function that takes in a character string and if the following two pieces of criteria are met:
1) the word is three letters
2) the second letter is A
then it returns 1. Otherwise, it returns 0. Here is what I have:
Code:
int determine(char word[10]) {
int fits = 1;
if (word[3] == '\0')
fits = 0;
else if (word[1] != 'A')
fits = 0;
return fits;
}
But for some reason, it always returns 0, no matter what, even when I write a word like CAR (not that the character strings will be all capital letters).
Help is appreciated, thanks.