//checkSetNotation.c //John T. Rine //October 15, 2011 #include"set.h" #include int checkSetNotation(char *inputString) { char oldChar = 'C'; int position = 0; int numberOfCharsInSet = 0; numberOfCharsInSet = cntChars(inputString); if(*(inputString + position) != '{') { printf("First character in a set representation must be a '{'\n"); return 0; } else if (*(inputString + numberOfCharsInSet - 1) != '}') { printf("Last character in a set representation must be a '}'\n"); return 0; } else if (*(inputString + numberOfCharsInSet - 2) == ',') { printf("Last two characters in a set representation can't be \",}\"\n"); return 0; } else if (*(inputString + 1) == ',') { printf("First two characters in a set representation can't be \"{,\"\n"); return 0; } while(*(inputString + position) != '\0') { if (*(inputString + position) == ',' && oldChar == ',') { printf("Can't have two adjacent commas in a set representation\n"); return 0; } oldChar = *(inputString + position); position ++; } return 1; }