November 2013
Beginner
325 pages
9h 47m
English
Write a function called spaceCount() that counts the space characters (ASCII 0x20) in a C string. Test it like this:
#include <stdio.h>
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;
}
Remember: when you run into '\0', you have reached the end of the string!
Read now
Unlock full access