bool bgstrCmp(const bgstr left, const bgstr right) { int i = 0; while(!charEqual(left[i], L'\0')) { if (!charEqual(left[i], right[i])) { return FALSE; } i++; } return charEqual(right[i], L'\0'); }
bool isPalindrome(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function bool bValidPalindrome = true; int n = s.size(); int front = 0; int back = n - 1; while (front < back) { while (front < back && !isAlphaNumeric(s[front])) front++; while (front < back && !isAlphaNumeric(s[back])) back--; if (front != back && !charEqual(s[front], s[back])) { bValidPalindrome = false; break; } front++; back--; } return bValidPalindrome; }
void bgstrLastChar(bgstr lastChar, const bgstr str) { int i = 0; while(!charEqual(str[i], L'\0')) { i++; } bgstrAssign(lastChar, str + i - 1); }
size_t bgstrLen(const bgstr str) { int i = 0; while(!charEqual(str[i], L'\0')) { i++; } return i; }
/* * Copy strings */ void bgstrAssign(bgstr dest, const bgstr src) { int i = 0; while(!charEqual(src[i], L'\0')) { dest[i] = src[i]; i++; } dest[i] = L'\0'; }
/* * Strip leading and trailing spaces. * TODO Actually implement it */ void stripSpaces(bgstr dest, const bgstr src) { int i = 0, k = 0; // Leading spaces while(!charEqual(src[i], L'\0') && charEqual(src[i], L' ')) { i++; } int start = i; i = bgstrLen(src) - 1; while(i > -1 && charEqual(src[i], L' ')) { i--; } int end = i + 1; bgstrSubstr(dest, src, start, end - start); }
int strIndexOf(const bgstr str, const bgstr pattern, int startFrom) { int i = 0; while(!charEqual(str[i], L'\0')) { if (bgStartsWith(str + startFrom + i, pattern)) { return i + startFrom; } i++; } return -1; }
bool bgStartsWith(const bgstr str, const bgstr pattern) { int i = 0; while(!charEqual(pattern[i], L'\0')) { if (str[i] != pattern[i]) { return FALSE; } i++; } return TRUE; }
readFile(char* fileName,char* fileToBeRead){ char dirSector[512]; char* dirSectorP = dirSector; int isEqual = 33; int i = 0; readSector(dirSector,2); while(i < 16){ isEqual = charEqual(dirSectorP,fileName,6); if (isEqual == 1){ dirSectorP = dirSectorP+6; readThisFile(dirSectorP,fileToBeRead); break; } dirSectorP = dirSectorP+32; ++i; } return; }