Here it is:
[code]#include <stdio.h>
#include <stdio.h>
#include <stdlib.h> //for malloc/free
#include <string.h> //for strlen
int spaceCount(const char *s)
{
int count = 0;
char space = 0x20;
for (int k = 0; k< strlen(s); k++) {
if (s[k]==space) {
count++;
}
}
return count;
}
int main(int argc, const char * argv[])
{
const char *sentence = “He was not in the cab at the time”;
printf("\"%s\" has %d spaces\n", sentence, spaceCount(sentence));
return 0;
}
[/code]