Grumpy already put you on the right track. I add that you could take advantage of two functions from the C standard library, namely isupper() and isspace(), defined in the ctype.h include.
Code:
#include <stdio.h>
#include <ctype.h>
#define MAX 100
int main() {
FILE *f = fopen( "text.txt", "r" );
char letters[MAX] = "";
int i, count=0;
if( f == NULL ) {
printf( "\n\nFile not opened!\n\n" );
return 0;
}
fgets( letters, MAX, f );
/*
Let's verify each character of letters[]. Whenever a character
is uppercase, we need to verify that the previous one is a space,
unless it's the first one in the string. We take advantage of two
functions from the ctype.h include here (isupper() and isspace()).
Whenever the "i==0" or the "isspace(letters[i-1])" condition is true,
1 is added to count (in C, true equals to 1 and false equals to 0).
*/
for( i=0; letters[i]; ++i )
if( isupper(letters[i]) )
count += i==0 || isspace(letters[i-1]);
printf( "\n\n%d\n\n", count );
return 0;
}
I hope this is not regarded as "spoon feeding" (I think it is not, but who knows?).