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++
- Line Splicing in C/C++
- How to write your own header file in C?
- Write a C program that won't compile in C++
- Write your own memcpy() and memmove()
- When should we write our own copy constructor?
- When should we write our own assignment operator in C++?
- Command line arguments example in C
- Command line arguments in C/C++
- Write a C macro PRINT(x) which prints x
- C program to write an image in PGM format
- Read/Write structure to a file in C