Recursion can be used to do both tasks in one line. Below are one line implementations for stracat() and strcmp().
The function my_strcmp() is simple compared to my_strcmp().
The above functions do very basic string concatenation and string comparison. These functions do not provide same functionality as standard library functions.
Please write comments if you find the above code incorrect, or find better ways to solve the same problem.
- Write a one line C function to round floating point numbers
- strcat() vs strncat() in C++
- strcmp() in C/C++
- Difference between strncmp() and strcmp in C/C++
- How to write your own header file in C?
- Write your own memcpy() and memmove()
- Write a C program that won't compile in C++
- When should we write our own copy constructor?
- When should we write our own assignment operator in C++?
- Write a C macro PRINT(x) which prints x
- Read/Write structure to a file in C
- How to write a running C code without main()?
- Write a program that produces different results in C and C++
- C program to write an image in PGM format
- Does C++ compiler create default constructor when we write our own?