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.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- 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++
- C program to print odd line contents of a File followed by even line content
- Write your own memcpy() and memmove()
- How to write your own header file in C?
- When should we write our own assignment operator in C++?
- When should we write our own copy constructor?
- Write a C program that won't compile in C++
- C program to write an image in PGM format
- 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++