#include <stdio.h>
#include <ctype.h>
#include <string.h>

struct stringStats
{
    int stringLength;
    int upperCaseCount;
    int lowerCaseCount;
    int digitCount;
    int spaceCount;
    int nonAlphaCount;
    int vowelCount;
    int specialCount;
    int otherCount;
    int hexCount;
    int octalCount;
    int binaryCount;
    int punctuatorCount;
    int controlCount;
    int printableCount;

};

// function prototype to get started, or better, use pointers */
struct stringStats getStringStats (char theString[]){
	//create structure and initialize all values to zero
	struct stringStats stats;
	stats.stringLength = strlen(theString);
    stats.upperCaseCount = 0;
    stats.lowerCaseCount = 0;
    stats.digitCount = 0;
    stats.spaceCount = 0;
    stats.nonAlphaCount = 0;
    stats.vowelCount = 0;
    stats.specialCount = 0;
    stats.otherCount = 0;
    stats.hexCount = 0;
    stats.octalCount = 0;
    stats.binaryCount = 0;
    stats.punctuatorCount = 0;
    stats.controlCount = 0;
    stats.printableCount = 0;
	
	int i;
	//loop through the string and increment each stat as 
	for (i=1; i<strlen(theString); i++){
		//!! that I use here is a little cursed - I'm using it to invert things twice.
		//I expected these functions to return 0 or 1, but many of them return
		//a random positive integer - because I want to use them to increment my
		//counters, this turns that into 0/1.
		char c = theString[i];
		char cl = isupper(c) ? tolower(c) : c;
	    stats.upperCaseCount += !!isupper(c);
	    stats.lowerCaseCount += !!islower(c);
	    stats.digitCount += !!isdigit(c);
	    stats.spaceCount += !!isblank(c);
	    stats.nonAlphaCount += !isalnum(c);
	    stats.vowelCount += (cl=='a'||cl=='e'||cl=='i'||cl=='o'||cl=='u'||cl=='y');
	    //I couldn't really determine what was meant by a special character.
	    //the best definition I could find was just characters that weren't alphanumeric or spaces,
	    //but that shares the same definition as 'other' and 'punctuator' which feels a bit weird.
	    stats.specialCount = (isprint(c) && !(isalpha(c) || isspace(c)));
	    stats.otherCount = (isprint(c) && !(isalpha(c) || isspace(c)));
	    stats.hexCount += !!isxdigit(c);
	    stats.octalCount += (c>47&&c<57); //check to see if it's in the 1-8 range
	    stats.binaryCount += (c == '0'||c=='1');
	    stats.punctuatorCount += (isprint(c) && !(isalpha(c) || isspace(c)));
	    stats.controlCount = !!iscntrl(c);
	    stats.printableCount = !!isprint(c);	
	}
	return stats;
	
}

int main(void) {
	// your code goes here
	
	struct stringStats stats = getStringStats("potato12345671234");
	printf("\n%d", stats.octalCount);
}
