コード例 #1
0
ファイル: string.c プロジェクト: hainp/bogo-c
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');
}
コード例 #2
0
ファイル: isPalindrome.cpp プロジェクト: tbian7/pst
    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;
    }
コード例 #3
0
ファイル: string.c プロジェクト: hainp/bogo-c
void bgstrLastChar(bgstr lastChar, const bgstr str) {
    int i = 0;
    while(!charEqual(str[i], L'\0')) {
        i++;
    }
    bgstrAssign(lastChar, str + i - 1);
}
コード例 #4
0
ファイル: string.c プロジェクト: hainp/bogo-c
size_t bgstrLen(const bgstr str)
{
    int i = 0;
    while(!charEqual(str[i], L'\0')) {
        i++;
    }
    return i;
}
コード例 #5
0
ファイル: string.c プロジェクト: hainp/bogo-c
/*
 * 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';
}
コード例 #6
0
ファイル: string.c プロジェクト: hainp/bogo-c
/*
 * 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);
}
コード例 #7
0
ファイル: string.c プロジェクト: hainp/bogo-c
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;
}
コード例 #8
0
ファイル: string.c プロジェクト: hainp/bogo-c
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;
}
コード例 #9
0
ファイル: kernel.c プロジェクト: mohamed-hussein-1/OSProject
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;
}