C programs must compile with no warnings or errors using: gcc -std=c11 -pedantic -Wall
Each source file must start with a comment containing your name and a description.
Rewrite each function in the following initial implementations p1.c so that the provided tester program tester.c encounters no errors:
// initial/bad implementations of some string functions // #include <string.h> #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) { return ""; } char *strncpy( char * restrict s1, const char * restrict s2, size_t n) { return ""; } char *strchr( const char *s, int c) { return ""; } 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 ""; }For each function, your implementation must be efficient and self-contained, and may not call any other functions.
The tester program tester.c was adapted from
the GNU C library glibc-2.36 source code, with rename.h
included to redefine the str...
and mem...
functions
to my_str...
and my_mem...
to avoid interference with the true string.h functions.
Download/view: a9.zip (all), p1.c, rename.h, tester.c, Makefile
VECR/a9 also contains copies of rename.h, tester.c, initial p1.c, and modified Makefile.