void tests() { char a[] = {"String."}; printf("%d\n", myStrlen(a)); char b[20] = {0}; myStrcpy(b, a); printf("%s\n", b); char c[20] = {0}; myStrcpy(c, a); myStrcat(c, b); printf("%s\n", c); printf("%d\n", myStrcmp(a, b)); printf("%d\n", myStrcmp(b, c)); }
void test_strcmp_same() { clear_all(); //same strings. n>strlen() strcpy(a,"abc"); strcpy(b,"abc"); int x=myStrcmp(a,b,5); assert(x==0); //accepted }
void test_strcmp_e2() { clear_all(); //compare 2 empty strings a[0]='\0'; b[0]='\0'; int x=myStrcmp(a,b,20); assert(x==0); //accepted }
void test_strcmp_d() { clear_all(); //different strings strcpy(a,"lol"); strcpy(b,"aol"); int x=myStrcmp(a,b,3); assert(x==1); //accepted }
void test_strcmp_e1() { clear_all(); //compare an empty string and non-empty string a[0]='\0'; b[0]='1'; b[1]='a'; int x=myStrcmp(a,b,20); assert(x==-1); //accepted }
void test_strcmp_sp() { clear_all(); //compare 2 strings with the same prefix //pref_len=2 a[0]='1'; a[1]='a'; b[0]='1'; b[1]='a'; a[2]='s'; b[2]='p'; int x=myStrcmp(a,b,2); assert(x==0); //accepted }
int main(int argc, char *argv[]) { //block of code for debugging purposes #if DEBUG fprintf(stdout, "%s\n%s\n%s\n", argv[1], argv[2], argv[3]); #endif if(myStrcmp(argv[1], "removeSpaces") == 0) { fprintf(stdout, "Change to: %s\n", removeSpaces(argv[2])); } else if(myStrcmp(argv[1], "switchCases") == 0) { fprintf(stdout, "Change to: %s\n", switchCases(argv[2])); }
int _tmain(int argc, _TCHAR* argv[]) { int c[10] = { 1,2,3,4,5,6,7,8,9,10 }; int d[10]; myMemcpy( d, c, sizeof( int )*10 ); outputArray( c, 10 ); outputArray( d, 10 ); printf( "%d\n", myMemcmp( c, d, sizeof( int )*10 ) ); myMemmove( c, &c[2], sizeof( int )*8 ); outputArray( c, 10 ); myMemmove( &c[2], c, sizeof( int )*8 ); outputArray( c, 10 ); myMemset( d, 0, sizeof( int )*10 ); outputArray( d, 10 ); char a[100] = "123456789"; char b[100] = "abcdefghijklmn"; printf( "%d\n", myStrlen( a ) ); printf( "%d\n", myStrlen( b ) ); printf( "%s\n", myStrcat( b, a ) ); //printf( "%s\n", myStrcat( a, &a[2] ) ); //printf( "%s\n", myStrcat( &a[2], a ) ); printf( "%s\n", a ); printf( "%d\n", myStrcmp( b, a ) ); printf( "%s\n", myStrcpy( b, a ) ); printf( "%s\n", myStrmove( a, &a[3] ) ); printf( "%s\n", myStrmove( &a[4], a ) ); printf( "%s\n", a ); return 0; }
int main(int argc, char *argv[]){ if(argc<3) return 1; printf("\nDiff : %d",myStrcmp(*++argv,*++argv)); }