// test implement strchr() // initial/bad implementations of some string functions // #include #include #include "rename.h" size_t strspn( const char *s1, const char *s2) { return 0; } size_t strcspn( const char *s1, const char *s2) { return 0; } char *strcat( char * restrict s1, const char * restrict s2) { return ""; } char *strcpy( char * restrict s1, const char * restrict s2) { // initial test return memmove( s1, s2, strlen(s2)+1); } // memcmp: if( s1[i] != s2[i]) return s1[i]-s2[i]; char *strncpy( char * restrict s1, const char * restrict s2, size_t n) { return ""; } char *strchr( const char *s, int c) { printf( "c = %i\n", c); c = (char) c; printf( "c = %i\n", c); size_t i = 0; // while( i >= 0) ??? while(1) { // while( s[i] != 0) ... if( s[i] == c) return (char *) &s[i]; if( s[i] == 0) break; // '\0' == 0 ++i; } return 0; } char *strrchr( const char *s, int c) { return ""; } char *strstr( const char *s1, const char *s2) { return ""; } void *memcpy( void * restrict v1, const void * restrict v2, size_t size) { return ""; } void *memset( void *v, int c, size_t size) { return ""; }